Reputation: 11
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.
Upvotes: 1
Views: 386
Reputation: 941208
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.
Upvotes: 2
Reputation: 74654
COM objects are often STA, which means that they can only be used by the thread that created them
Upvotes: 2