Suppose that my application is composed of 3 components. They are:
- c++ native library
- c++ cli managed library, which wraps native library
- c# gui application.
As I understand, any native exception, thrown from a native c++ library will be wrapped with SEHException managed class. I am interested in the next steps, what is recommended to do after the creation of such an exception object.
Should I catch all such possible exceptions within the c++ cli managed library then create an appropriate managed exception? Something like this:
void some_managed_action()
{
try
{
native_object->some_native_action();
}
catch (const NativeException& e)
{
// What should I do with exception e and native object? before throwing new managed exception
// Will SEH wrapper automatically delete native exception object
// delete all native objects?
throw gcnew ManagedException(get_message(e));
}
}
Maybe there are some pitfalls in such an approach? Thanks for any advice.