Home > OS >  WPF default behavior on exceptions
WPF default behavior on exceptions

Time:09-16

Please note that I'm aware of possible solution and have read some other SO posts which will answer the question how to handle unhandled exceptions globally and I'm not asking if it is good practice or not. What I'm asking is why WPF application closes on exception (which I always thought is expected behaviour). However when researching how to implement the Exception handling globally in WPF I encountered this sentence on the Microsoft documentation page:

By default, Windows Presentation Foundation catches unhandled exceptions, notifies users of the exception from a dialog box (from which they can report the exception), and automatically shuts down an application.

But may experience is different, the application just exits without any warning, so any unhandled exception will be total mystery for the user and me as a developer. My question is really: Am I missing something, or is Microsoft wrong about their own framework?

CodePudding user response:

The docs seems to be wrong.

By default, a WPF application exits without any dialog box when an unhandled exception is thrown on the dispatcher thread.

You may consider to edit the docs and submit a PR on GitHub by clicking on the "Edit" button in the top right corner of the page.

  • Related