I’m trying to use the .NET debugging API from C++.
For this I initialize it like this (I removed some checks to make the code more compact and to the point):
typedef HRESULT (STDAPICALLTYPE *CreateDebuggerFunc)(int debuggerVersion, LPCWSTR szDebuggeeVersion, IUnknown ** ppCordb);
HMODULE mscoree = LoadLibraryA("mscoree.dll");
CreateDebuggerFunc CreateDebugger = (CreateDebuggerFunc)GetProcAddress(mscoree, "CreateDebuggingInterfaceFromVersion");
const int iDebuggerVersion = CorDebugVersion_2_0; // if we’re a v2.0 debugger.
IUnknown* unknown = NULL;
wchar_t * szEverettVersion = L"v2.0.50727";//v4.0.30319";
HRESULT res = CreateDebugger(iDebuggerVersion, szEverettVersion, &unknown);
res = unknown->QueryInterface(IID_ICorDebug, (void**) &m_core);
res = m_core->Initialize();
NetCallbacks* test = new NetCallbacks();
res = m_core->SetManagedHandler(test);
The NetCallbacks class is currently just a dummy class which implements empty methods of ICorDebugManagedCallback and ICorDebugManagedCallback2.
But for some reason when I call m_core->SetManagedHandler, I get E_NOINTERFACE.
How can that be? If I didn’t implement all the necessery method, I wouldn’t be able to create an object of NetCallbacks.
What am I doing wrong?
ok, it seems that the managed callbacks class should not be a dummy class.
It must implement some stuff itself.
http://blogs.msdn.com/b/mithuns/archive/2006/12/22/why-does-icordebug-setmanagedhandler-return-e-nointerface.aspx