Reputation: 1
I registered my very simple native COM server and my native COM client can call the COM method successfully. However, my managed COM client threw below error:
Unable to cast COM object of type 'DevicesLib.MyComClass' to interface type 'DevicesLib.IMyComInterface'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{503DDA5C-F8A2-4273-810F-3855EE0F2B78}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
I used tlbimp.exe to generate a delay signed interop dll. My OS is 64 bit windows server 2008 R2.
Any idea?
Thanks Leon
Upvotes: 0
Views: 283
Reputation: 1614
Your interface must not be registered for marshaling. Your CoClass is probably registered as requiring an STA. Without the STAThreadAttribute, the main thread is MTA. Creating the COM object puts it in a different STA thread, and then tries to marshal the interface pointer back to you.
Upvotes: 1