I hit the submit button accidently and I posted the entire code in the next post. For some reason, I dont see that post anymore.

Rather than posting the code again, let me try to keep things brief this time.

I have an out of proc COM server, which is an MFC app, which implements a single COM component. I am using MFC COM support (BEGIN_INTERFACE_PART/END_INTERFACE_PART macros in header file and BEGIN_INTERFACE_MAP/END_INTERFACE_MAP macros in CPP file). The COM server implements class factory, in addition to the single COM component. My component does not implement IDispatch interface, only a custom interface. The class that implements my component is derived from CCmdTarget.

I have a C++ client which calls:

HRESULT hr = ::CoCreateInstance(
CLSID_MYCOMSERVER,
NULL,
CLSCTX_LOCAL_SERVER,
IID_IMyInterface,
(LPVOID FAR *) &pComponent );

I traced the call to CoCreateInstance via debugger.

The debugger shows that my class factory's CreateInstance method is called, which successfully creates my component.

Then, QueryInterface method of my component is called 5 times by the COM library: once each for IID_IMarshal, IID_IStdMarshalInfo, IID_IExternalConnection, IID_IUnknown and IID_IMyInterface. The methods return E_NOINTERFACE for the first three interfaces, but return success code (S_OK) for the last two.

The CoCreateInstance eventually return E_NOINTERFACE to the client.

Is it because my COM component does not implement IMarshal, IStdMarshalInfo and IExternalConnection interfaces? How do add their implementation then?