CoCreateInstance fails in debug mode but works in release...
Posted on 2004-10-15
I have a windows service that creates an instance of an ATL COM object using CoCreateInstance. When the ATL COM object is compiled in DEBUG mode that service can successfully create an instance, however when the COM object is compiled in RELEASE mode the call to CoCreateInstance fails with the code E_OUT_OF_MEMORY.
In the service I include the object.h and object_i.c files. I also link to the object.lib file.
ILPS* pLPS = NULL; // Pointer to the LPS interface
CLSID clsid; // The CLSID of the LPS interface
HRESULT hr; // Error Code for COM
CoInitialize(0); // This must be called for every thread
// Get the CLSID of the LPS interface
hr = CLSIDFromProgID(OLESTR("LPSCORE.LPS"),&clsid);
// Create an instance of the LPS interface
hr = CoCreateInstance(clsid,NULL,CLSCTX_SERVER,IID_ILPS,(void**)&pLPS);
I have checked the registry after building in both modes and it looks right!
Anyone have this happen to them before, or know what is causing this?