In my application, I create an object A, that creates an object B, both via CreateInstance
. Both objects should live in the same process.
Now I see that object B, when asked for a certain interface, is returning E_NOINTERFACE, although I defined it in the COM_MAP:
class B:
{
// ....
BEGIN_COM_MAP(B)
COM_INTERFACE_ENTRY(IB)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IXXX) // the interface I'm interested in
END_COM_MAP()
// .....
};
And the A code:
#define FORWARD_ERROR( expr ) { hr=expr; if( !SUCCEEDED( hr ) ) return hr;}
IBPtr b;
FORWARD_ERROR( b.CreateInstance( __uuidof( B ), 0, CLSCTX_INPROC_SERVER ) );
IXXXPtr x;
HRESULT hrIf = b.QueryInterface( __uuidof( IXXX ), x );
// ===> now x is NULL, and hrIf contains E_NOINTERFACE
When I debug this, and put a breakpoint in the COM_MAP, I don't see my source code in the lowest frame, but some ole32.dll's CRpcThread::WorkerLoop
.
I have no clue how I indicated that the QueryInterface
should be called via OLE and RPC. Any ideas?