开发者

System.InvalidCastException when using a COM interface

I wrote a atl COM dll, dual. And used one of its intreace X in a C# GUI proj. when call X.F(), I got an System.InvalidCastException, can not cast namespace.XClass to namespace.IX, QueryInterface failed: BADTYPE. The call was in my own thread.

If i move the code to the GUI thread, it works just fine.

Please help me with that. 开发者_运维知识库Thanks a lot.


COM objects are often STA, which means that they can only be used by the thread that created them


COM requires a proxy/stub to marshal the call from the thread to the thread that created the object. QI will fail if it cannot find it in the HKCR\Interface registry key.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜