Question

I define my interfaces in an A.idl file, which I compile to A.tlb

In a VS2005 ATL project "B" I use importlib(A.tlb) in B.idl and #import "A.tlb" in stdafx.h and implement an interface IA from A.tlb in an ATL COM class. The project outputs a B.dll and a B.tlb

I add the B.tlb to refererences of a C# application and within the code I instantiate the COM object.

The instantiation works without problems if I use either

Type.GetTypeFromCLSID(); Activator.CreateInstance(...);

or

[DllImport("ole32.dll", ...)] CoCreateInstance(...)

Both work fine, the object instantiates and I can cast it to IA interface defined in A.tlb (actually a RCW generated from the tlb) and invoke its methods. Still no problems.

Then I use OLEView to enable the COM object activation using the default DllHost.exe surrogate.

The instantiation of the COM object within the surrogate (parameter CLSCTX_LOCAL_SERVER in CoCreateInstance) is still without problems, but when I try to cast the object to the IA interface defined in A.tlb I get E_NOINTERFACE and a message saying QueryInterface failed because "No such interface supported".

Please help. What could be wrong? If you need any additional info, I'll try to provide as much as possible.

Was it helpful?

Solution

You need to build and register the proxy/stub DLL. Required to marshal the interfaces across process boundaries. I can't find a great MSDN page for it, but it is mentioned here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top