Is it possible to capture native unhandled exceptions in UWP apps?

383 Views Asked by At

Our UWP app is mainly in C# but has a native DLL. When native code crashes CoreApplication.UnhandledErrorDetected is not fired (we have a C# handler for it). We have tried calling SetUnhandledExceptionFilter in the DLL, but our handler is not invoked.

BTW, CRT handlers do work (e.g. _set_invalid_parameter_handler).

In https://social.msdn.microsoft.com/Forums/windowsapps/en-US/9cddf0bc-8277-4534-b2c5-a96b9012e569/uwpc-is-it-possible-to-capture-unhandled-exceptions?forum=wpdevelop was a recommendation to use CoreApplicationExceptionHandler::OnUnhandledException.

I have tried embedding CoreApplicationExceptionHandler::OnUnhandledException in the native DLL and it has not helped at all.

  1. If the capturing is set in C# (first) the native handler is not invoked. It is invoked only if it is the first set (although in my test the handler propagates the exception).
  2. Native crashes in non WinRT code are not caught by the handler.

So how can native exceptions be captured???

A demo solution showing the problem is available here: https://drive.google.com/file/d/1-6r-XrOe6cRhZduRNA2HnhLm7eKQlGFU/view?usp=sharing

Thanks

0

There are 0 best solutions below