以下多个communicatorAPI指南后,我似乎被卡住了。总的来说,它归结为无法将信使对象作为接口。无论是信使obj还是信使类obj类。无法将类型为'CommunicatorAPI.MessengerClass'的COM对象转换为接口类型为'CommunicatorAPI.IMessengerAdvanced'
试图转换对象时,我收到以下异常。
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)).
这是我试图运行的代码的一个例子,剥离到只是抛出异常。
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);
}
}
}
}
我也尝试了上述代码,使用“Messenger msgr = new Messenger();”没有运气。
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)).
我对c#非常陌生,而且我已经和CommunatorAPI一起工作了。顺便说一句,参考文献被添加。 Embed选项是错误的,我很难过。不知道有没有人找出解决方案。
此外,我已经实例化了一些效果如下的接口:“msgAdv = msgr as IMessengerWndAdvanced;” 没有运气。变量msgAdv每次都是空的。我尝试了M $的不同例子,但无济于事。此外,我已阅读SDK附带的“OCSDK.chm”帮助文件。没有提及“HRESULT异常:0x80004002(E_NOINTERFACE)”错误。
帮助?
在我所有的尝试,我已经签署因此,msgr.SignIn(blah blah)或msgr.AutoSignIn()不是必需的。其实,再次这样做,挂断了沟通。虽然谢谢! :) – embeddednerd
哦,我已经尝试了MessengerClass msgr = new MessengerClass();作为Messenger msgr =新的Messenger()引发了类似的异常。我相信在http://msdn.microsoft.com/en-us/library/bb787245(v=office.12).aspx的底部有人建议MessengerClass是正确的类。 – embeddednerd
这意味着你的服务器配置的方式不提供必要的接口......它不是你的代码,但导致“IMessengerAdvanced”不可用的服务器配置我认为 – Yahia