Why is my call to System.String.Format() from hosted CLR failing

0

I have a simple C++ program that I am trying to call System.String.Format() from via a new hosted CLR instance. it fails when it actually calls _Type::InvokeMember_3 (I'd appreciate corrections to that notation).

//Load up the hosted clr
. . .
_Type spType = null;
. . . // set spType to System.String
HRESULT result = spType->InvokeMember_3(bstrStaticMethodName, static_cast<BindingFlags>(
    BindingFlags_InvokeMethod | BindingFlags_Static | BindingFlags_Public), 
    NULL, vtEmpty, psaWriteLineArgs, &vtLengthRet);
if (FAILED(result))
{
    wprintf(L"Failed to invoke System.String.Format() w/hr 0x%08lx\n", result);
}

The error I get is: sFailed to invoke System.String.Format() w/hr 0x80131604 The error message for that HRESULT is Uncaught exception thrown by method called through Reflection

Update: If I configure all first chance exceptions to get thrown I get the following stacktrace at the line in question:

Stacktrace The full code is here. I've reduced it as much as possible. I've tried the on Visual Studio 2010 on Windows 7 and Visual Studio 2012 on Windows 8.

What can I do to catch the exception?

c++
clr-hosting
asked on Stack Overflow Dec 30, 2012 by Justin Dearing • edited Dec 30, 2012 by Justin Dearing

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0