I have a C++ DLL compiling with /clr. Something (which I cannot reproduce in a new project) is causing all exceptions thrown to be wrapped in a System::Exception. The System::Exception is thinly wrapping an SEHException.
This is occurring in a managed class, within a generic method.
My understanding is that all exceptions start as SEHExceptions, but the .NET framework maps them to the correct types for catch statements. That is not happening here.
public ref class Foo
{
generic<typename T> void bar()
{
try
{
throw 42;
}
catch (int errno) { /*do something*/ }
catch (System::Exception^ ex) { /*WTF?*/ }
}
}
Only the second catch statement is entered. I guess my question is, WTF?