.NET via unmanaged C++ COM
-
I have the following method that instantiates a specified class in a given .NET assembley with specified activation attributes. HRESULT LoadCORClassEx( BSTR AssemblyName, /* mscorlib */ BSTR typeName, /* System.Text.RegularExpressions.Regex */ REFIID riid, void **ppv, SAFEARRAY *args) { HRESULT hr = S_OK; if(ppv == NULL) return E_POINTER; *ppv = 0; /*** debug ***/ VARIANT var; HRESULT hresult; long ix = 0; VariantInit(&var); hresult = SafeArrayGetElement( args, &ix, &var); if(FAILED(hresult)) return hresult; /*** end debug ***/ CComPtr<_ObjectHandle> spHandle; spHandle.p = g_host.spDefaultAppDomain->CreateInstance_2( AssemblyName, typeName, args); CComVariant unwrapped; unwrapped = spHandle->Unwrap(); if (unwrapped.vt != VT_UNKNOWN && unwrapped.vt != VT_DISPATCH) return E_UNEXPECTED; return unwrapped.punkVal->QueryInterface(riid, ppv); } I can get the contents of the args SAFEARRAY that is passed into this method into a variant -- shown in the debugger as {"abc" VT_BSTR} -- before the subsequent call to CreateInstance_2(), however, when I step into the call to CreateInstance_2(), the underlying raw_CreateInstance_2() call in mscorlib.tli blows up :((. Can anyone see what I am doing wrong here? I tried adding the save /*** debug ***/ code to mscorlib.tli in order to peek at the content of the SAFEARRAY being passed for activation attributes, but the debugger seems to ignore the added code... Thanks for any insights! -- Roy