我正在尝试使用C ++的.NET调试API 为此,我将其初始化为此(我删除了一些检查以使代码更紧凑和重点):
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);
NetCallbacks
类目前只是一个虚拟类,它实现了ICorDebugManagedCallback和ICorDebugManagedCallback2的空方法。
但出于某种原因,当我调用m_core-> SetManagedHandler时,我得到了E_NOINTERFACE。
怎么可能?如果我没有实现所有necessery方法,我将无法创建NetCallbacks
的对象。
我做错了什么?
答案 0 :(得分:0)
好吧,似乎托管回调类不应该是虚拟类 它必须自己实施一些东西 http://blogs.msdn.com/b/mithuns/archive/2006/12/22/why-does-icordebug-setmanagedhandler-return-e-nointerface.aspx