I have an app which terminates unexpectedly sometimes in spite of existence of handlers for AppDomain.CurrentDomain.UnhandledException, Application.Current.DispatcherUnhandledException, TaskScheduler.UnobservedTaskException events.
This is a WPF app with many P/Invoke interop code. I've created "safety-net" with handlers for all "last resort" events (see above). But the app still fails with standard Windows error dialog missing all my handler.
What can be a cause for .net app termination and avoiding AppDomain.CurrentDomain.UnhandledException ?
Can an exception in unmanaged thread be such a cause? If so what can I do with it?
The CLR cannot magically inject unhandled exception handling into native pinvoked code when that code itself doesn't take care of it. Particularly any kind of hardware exception like AccessViolation in a thread that the CLR doesn't know about will terminate the app without a diagnostic. You'll need to work with the owner or author of that code to improve the reliability and maintainability of that code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With