After following multiple communicatorAPI guides I seem to be stuck. In general it boils down to the inability to cast an messenger object as an interface. Whether it's the messenger obj or the messengerclass obj classes.
Upon attempting to cast the object, I recieve the following exception.
Unable to cast COM object of type 'CommunicatorAPI.MessengerClass' to interface type 'CommunicatorAPI.IMessengerAdvanced'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DA0635E8-09AF-480C-88B2-AA9FA1D9DB27}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
This is an example of the code I am trying to run, stripped down to just what throws the exception.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommunicatorAPI;
namespace OCA
{
class OCA_main
{
static void Main(string[] args)
{
OCA m = new OCA();
m.subscribe();
m.startconvo("emailaddress");
}
}
class OCA
{
MessengerClass msgr = new MessengerClass();
// Messenger msgr = new Messenger(); //Tried this too... :(
IMessengerAdvanced msgrAdv;
public void subscribe()
{
msgr.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(msgr_OnIMWindowCreated);
}
public void unsubscribe()
{
msgr.OnIMWindowCreated -=new DMessengerEvents_OnIMWindowCreatedEventHandler(msgr_OnIMWindowCreated);
}
void msgr_OnIMWindowCreated(object pIMWindow)
{
try
{
IMessengerAdvanced msgrAdv = (IMessengerAdvanced)msgr;
}
catch (Exception ex)
{
Console.WriteLine("{0}", ex.Message);
}
throw new NotImplementedException();
//... stuff
}
public void startconvo(string users)
{
try
{
IMessengerAdvanced msgrAdv = (IMessengerAdvanced)msgr;
}
catch (Exception ex)
{
Console.WriteLine("{0}", ex.Message);
}
}
}
}
I have also tried the above code using "Messenger msgr = new Messenger();" With no luck.
Unable to cast COM object of type 'CommunicatorAPI.MessengerClass' to interface type 'CommunicatorAPI.IMessengerAdvanced'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DA0635E8-09AF-480C-88B2-AA9FA1D9DB27}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I am horribly new to c#, and I have come to a stand still with working with the communicatorAPI. Btw, the references are added. The Embed option is false, and I am stumped. Wonder if anyone has figured out a solution.
Also, I have instantiated the interface with something to effect of: "msgAdv = msgr as IMessengerWndAdvanced;" with no luck. The variable msgAdv is null every time. I have tried the different examples from M$ and to no avail. Moreover, I have read through the "OCSDK.chm" help file that came with the SDK. There isn't a mention of the "Exception from HRESULT: 0x80004002 (E_NOINTERFACE)" error.
Help?