我有以下代码:
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 ( )
}
使用线程时,我收到以下异常:
无法将类型为“System.__ComObject”的COM对象强制转换为接口类型“IMyInterface”。 此操作失败,因为对具有IID“{GUID}”的接口的COM组件进行QueryInterface调用时出错:不支持此类接口
但是该接口应该被很好地支持?任何人对这里发生了什么有什么想法吗?