Here are sample projects showing how to display a custom dialog box when an unhandled exception occurs in:
- A Console application
- A WinForm application
- A WPF application
Exceptions are caught only if the debugger is attached. In other word, they are still caught by Visual Studio, but your customer will always see the custom dialog box.
The principle is simple:
- Attach to event
AppDomain.CurrentDomain.UnhandledException - Check
System.Diagnostics.Debugger.IsAttached - Show custom dialog
- Exit the application