I created simple COM out-of-proc EXE server (CLSCTX_LOCAL_SERVER) using ATL project in Microsoft Visual Studio 2008. Also I added my class and my interface to the project. I don't need Automation, so I don't want to derive from IDispatch and my interface is not dual interface. Here is CMyClass definition in the header file:
MYSTRUCT structure (and PMYSTRUCT pointer) is defined in project's *.idl file and resides in MyServer_i.h header file generated by MIDL compiler. CreateMyObject method is defined in correspondent *.cpp file of CMyClass.Code:#pragma once #include "resource.h" // main symbols #include "MyServer_i.h" class ATL_NO_VTABLE CMyClass : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CMyClass , &CLSID_MyClass>, public IMyClass { public: CMyClass() { } DECLARE_REGISTRY_RESOURCEID(IDR_MYCLASS) DECLARE_NOT_AGGREGATABLE(CMyClass) BEGIN_COM_MAP(CMyClass) COM_INTERFACE_ENTRY(IMyClass) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } public: // IMyClass interface STDMETHOD(CreateMyObject)(ULONG ulType, PMYSTRUCT pMyStruct, ULONG* ulObjID); }; OBJECT_ENTRY_AUTO(__uuidof(MyClass), CMyClass)
Well, this project is compiled and linked perfectly without any problems.
My problem is that when I try to call CoCreateInstance of CMyClass COM object from different client appication and requesting IMyClass interface it fails to do so (returns NULL pointer). When I open OleView.exe application It shows My class in registered objects, but there is no IMyClass interface in the object. The interesting thing is that when I look to the type library (again using OleView) I can see IMyClass interface, CMyClass object and MYSTRUCT structure. I'm thinking might be COM_INTERFACE_ENTRY(IMyClass) macro somehow doesn't put IMyClass interface into CMyClass object interface MAP.
BTW if I use dual interface (IMyClass is derived from IDispatch using IDuspatchImpl) all is working (I can get IMyClass interface from client application). But I don't need to support IDispatch.
Any ideas?


Reply With Quote

Bookmarks