问题
I have an application containing both managed and native code. The application currently has an unhandled exception filter, set via SetUnhandledExceptionFilter, which catches any critical errors, generates a minidump, records various application parameters, and exits the program.
The unhandled exception handler does not catch an EngineExecutionException which occurs in the .NET runtime. We suspect the problem is memory corruption caused by the native portion of the application.
The problem is, when the exception occurs, the application just exits without a trace. We'd like to record a minidump when this happens. Does anyone know how our application can install a handler capable of catching this?
回答1:
AFAIK this exception is not catchable on the managed side of things (at least not in .NET 4).
One way to "catch" it would be to create a (native) custom starter/loader for your application which loads the .NET runtime - this custom starter can install an exception handler on the native side of .NET runtime.
Reference links:
- http://msdn.microsoft.com/en-us/magazine/cc163567.aspx
- http://msdn.microsoft.com/en-us/library/ms164336.aspx
- http://msdn.microsoft.com/en-us/library/dd380851.aspx
- http://msdn.microsoft.com/en-us/library/ms231221.aspx
来源:https://stackoverflow.com/questions/9182387/catching-engineexecutionexception