Anyone with experience in out-of-proc COM servers?
-
I'm trying to write a COM .exe server that creates a small modeless dialog box when properly called. Unfortunately, when I call the COM object from my application, it always returns E_NOINTERFACE from CoCreateInstance when given the correct IID of my COM interface (ICObject in this case, for test purposes). According to MFC documentation, this error occurs when the QueryInterface call does not support the requested interface. However, if I create the same exact COM project using an in-proc .dll file, without changing a single line of code in the calling application (except the CLSCTX_ string in CoCreateInstance), it works fine. I am using MFC's ATL/COM wizard to create both the .exe and the .dll projects. Both settings are for apartment model threading, custom interface, no aggregation and connection points. Here's my application code: ////////////////////////////////////////////// #include "..\COMObject\COMObject.h" #include "..\COMObject\COMObject_i.c" ... HRESULT hr; //instantiate it hr = CoCreateInstance(CLSID_CObject, NULL, CLSCTX_LOCAL_SERVER /*CLSCTX_INPROC_SERVER for DLL*/, IID_ICObject, (void **) &m_pObject); //do something with it if(SUCCEEDED(hr)) { m_pObject->StartDialog(); } ////////////////////////////////////////////// Does anyone have any idea why it works with an in-proc .dll and not an out-of-proc .exe?
-
I'm trying to write a COM .exe server that creates a small modeless dialog box when properly called. Unfortunately, when I call the COM object from my application, it always returns E_NOINTERFACE from CoCreateInstance when given the correct IID of my COM interface (ICObject in this case, for test purposes). According to MFC documentation, this error occurs when the QueryInterface call does not support the requested interface. However, if I create the same exact COM project using an in-proc .dll file, without changing a single line of code in the calling application (except the CLSCTX_ string in CoCreateInstance), it works fine. I am using MFC's ATL/COM wizard to create both the .exe and the .dll projects. Both settings are for apartment model threading, custom interface, no aggregation and connection points. Here's my application code: ////////////////////////////////////////////// #include "..\COMObject\COMObject.h" #include "..\COMObject\COMObject_i.c" ... HRESULT hr; //instantiate it hr = CoCreateInstance(CLSID_CObject, NULL, CLSCTX_LOCAL_SERVER /*CLSCTX_INPROC_SERVER for DLL*/, IID_ICObject, (void **) &m_pObject); //do something with it if(SUCCEEDED(hr)) { m_pObject->StartDialog(); } ////////////////////////////////////////////// Does anyone have any idea why it works with an in-proc .dll and not an out-of-proc .exe?
-
Are you sure CLSID_CObject and IID_ICObject are the same in .DLL and .EXE COM implementation? Check .IDL files they have to be the same for both types of projects (.EXE and .DLL) or just use one .IDL file for both projects. soptest
I just tried creating a wholly other .exe server in a new directory with a new interface CLSID and IID. Still has the same methods as the previous attempts and the application still gave the E_NOINTERFACE error. For some reason it will not find the interface requested for an .exe server. I searched through the messages and there's one other one back in the annals describing the same exact problem (search for NOINTERFACE).
-
I just tried creating a wholly other .exe server in a new directory with a new interface CLSID and IID. Still has the same methods as the previous attempts and the application still gave the E_NOINTERFACE error. For some reason it will not find the interface requested for an .exe server. I searched through the messages and there's one other one back in the annals describing the same exact problem (search for NOINTERFACE).
-
I'm trying to write a COM .exe server that creates a small modeless dialog box when properly called. Unfortunately, when I call the COM object from my application, it always returns E_NOINTERFACE from CoCreateInstance when given the correct IID of my COM interface (ICObject in this case, for test purposes). According to MFC documentation, this error occurs when the QueryInterface call does not support the requested interface. However, if I create the same exact COM project using an in-proc .dll file, without changing a single line of code in the calling application (except the CLSCTX_ string in CoCreateInstance), it works fine. I am using MFC's ATL/COM wizard to create both the .exe and the .dll projects. Both settings are for apartment model threading, custom interface, no aggregation and connection points. Here's my application code: ////////////////////////////////////////////// #include "..\COMObject\COMObject.h" #include "..\COMObject\COMObject_i.c" ... HRESULT hr; //instantiate it hr = CoCreateInstance(CLSID_CObject, NULL, CLSCTX_LOCAL_SERVER /*CLSCTX_INPROC_SERVER for DLL*/, IID_ICObject, (void **) &m_pObject); //do something with it if(SUCCEEDED(hr)) { m_pObject->StartDialog(); } ////////////////////////////////////////////// Does anyone have any idea why it works with an in-proc .dll and not an out-of-proc .exe?
You should use (and register) the proxy/stub for your EXE server. Or you should use the dual interfaces, derived from IDispatch, or/and oleautomation interfaces, derived from IUnknown, with standard OLE marshalling. For it, you should use the oleautomation compatible types of data, such as long, double, BSTR and so on. In this case, you don't need any additional proxy/stub. With best wishes, Vita
-
You should use (and register) the proxy/stub for your EXE server. Or you should use the dual interfaces, derived from IDispatch, or/and oleautomation interfaces, derived from IUnknown, with standard OLE marshalling. For it, you should use the oleautomation compatible types of data, such as long, double, BSTR and so on. In this case, you don't need any additional proxy/stub. With best wishes, Vita