I am creating a COM object (from native code) using CoCreateInstance:
const
CLASS_GP2010: TGUID = "{DC55D96D-2D44-4697-9165-25D790DD8593}";
hr = CoCreateInstance(CLASS_GP2010, nil, CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER, IUnknown, out unk);
Actually, I'm in Delphi, which means I call the helper function:
CreateComObject(CLASS_GP2010);
Most of the time this function succeeds. But sometimes, in the same executable, in the same process, the call to CoCreateInstance fails with:
Unspecified error (0x80004005 = E_FAIL)
Calling the function again may succeed, or may fail. There's no (apparent) rhyme or reason.
It's not my COM dll
If this were a normal COM dll that I wrote, I would start placing OutputDebugString in DLL_ATTACH, and when someone tries to call DllGetClassObject, I would confirm that COM is correctly loading my DLL, and that it is correctly asking for a class to be instantiated.
Unfortunately it's not a COM dll; it's a .NET assembly dll. And the COM subsystem does not simply "load" my dll. Instead, COM is instructed to load mscoree.dll:
HKEY_CLASSES_ROOT
CLSID
{DC55D96D-2D44-4697-9165-25D790DD8593}
InprocServer32
@default = mscoree.dll
And mscoree.dll exports the required GetClassObject function. So mscoree.dll is the one returning E_FAIL, not me. The failure never happens on my development machine, but consistently intermittently fails on the customers machines.
How do I enable .NET logging?
T