Using the code sample here: Calling A .NET Managed Method from Native Code
With only the following change:
Throw ApplicationException derived exception in Test method
public class TestException : ApplicationException
{
public TestException(string message)
: base(message)
{
this.HResult = unchecked((int)0x80040201);
}
}
public class Class1
{
public void Test()
{
throw new TestException("test");
}
}
Rebuilding and running the application shows that the call to InvokeMember_3 throws a _com_error with an HRESULT error code of 0x80131604 COR_E_TARGETINVOCATION (TargetInvocationException).
How can I get the real HRESULT 0x80040201?
Thank you.
Edit
I've updated my question a little and posted the complete sample solution here: kb953836.zip
User contributions licensed under CC BY-SA 3.0