Hi
Is there any way to handle all Errors Exceptions and crashes in WPF application? I know about DispatcherUnhandledException, but it handles only exceptions in UI thread, isn't it? Is there a way to catch and log all exceptions in other threads? and binding errors too? How do you implement this kind of requirement in your enterprice system?
views:
806answers:
3AppDomain.CurrentDomain.UnhandledException
Will catch any unhandled exceptions for the current thread. This is how we handle it in our application.
BindingErrors are always handled and logged to the output window. Before a release we check the output window for binding errors and fix as many as we can.
However it is my opinion that you would not want to treat binding errors as unhandled as they mostly recoverable and should be fixed as best you can before each release. You can change Debug > Exeptions in Visual Studio to make it throw BindingFailure to get more specific information.
HTH,
Dennis
Keep in mind, that Microsoft does not recommend catching all exceptions, instead they recommend to catch only exceptions you know (or expect to happen in some place). Even more if you want to get "Certified for Microsoft [Windows|Vista]" logo, you must not catch unknown exceptions, and such exceptions must go to Wer.
Yes, there are 3 places:
- place
Application.Run()
intotry
...catch
DispatcherUnhandledException
AppDomain.CurrentDomain.UnhandledException
In either case you should display a please-forgive-me message and suggest to send an error report.
The service on your server should answer either 'thank you for submitting error report' or 'the problem is already fixed in the next version. please update'