的COM对象,我有以下代码:无法投类型的异常
public void Test(IMyInterface iInterface)
{
iInterface.CallMethod ();
}
工作正常。但是,如果我更改代码以被拧:
private IMyInterface myInterface;
public void Test(IMyInterface iInterface)
{
myInterface = iInterface;
new Thread (new ThreadStart (CallInterfaceMethod)).Start ();
}
public void CallInterfaceMethod ()
{
myInterface.CallMethod ()
}
当我使用线程我收到异常:
无法转换类型的COM对象“系统.__ ComObject”到接口类型“IMyInterface的” 。 此操作失败,因为IID为{{GUID}的接口的COM组件上的QueryInterface调用失败,原因如下错误:没有此类接口支持
但接口应该支持就好了吗?任何人对这里发生的事情有任何想法?
http://blogs.msdn.com/b/oldnewthing/archive/2004/12/13/281910.aspx – EricLaw 2015-10-20 18:20:08