When an exception goes uncaught in a .NET app, the virtual machine displays an error message to the user. I'd like to be able to display my own error message, without having to put a catch
block at the top level of my app (because that makes debugging uncaught exceptions more tedious).
Right now I display my own error dialog in an AppDomain.UnhandledException
event listener, but the .NET-created dialog still shows up. I'd also like to avoid Environment.FailFast
as that would bypass my finally
blocks (to which I'm still somewhat attached).
If this is WinForms, you have to handle AppDomain.UnhandledException and Application.ThreadException to catch them all. Some exceptions filter into one and others into the other.
There was a similar (but not exact duplicate) question here that should help: C# - WinForms - Exception Handling for Events
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