14.5 Catching Unmanaged C++ Exceptions
When an unmanaged C++ object of type U is thrown, it is "wrapped" with a common language runtime exception of type
When searching for the appropriate
catch clause, if the type of the
catch clause is an unmanaged C++ type, the thrown object is unwrapped and compared to the unmanaged C++ type. This enables an unmanaged C++ exception to be caught in the normal way.
However, if a
catch clause of type
SEHException or any of its base classes comes first, it will intercept the exception. It is therefore advisable to place all catch clauses that catch unmanaged C++ exceptions before any
catch clauses of managed exceptions.
will both catch any thrown type including SEH exceptions.
If an unmanaged type is caught by
catch(Object*), it will not destroy the thrown object.
When throwing or catching unmanaged C++ exceptions, one of the C++ exception handling compiler options must be used: /GX, /EHs, or /Eha.