I have a MDI parent / children application.
In the Program.cs file I have a global exception handler for both ThreadException and UnhandledException.
Those are working fine.
When I get an unhandled exception at the global level, inside the UnhandledException handler I call Environment.Exit(1) to close the application since I don't know the current state of the application.
In the child forms I "normally" add the following to event handlers.
try
{
// Some Code
}
catch (Exception ex)
{
HandleException(ex);
MessageBox.Show("Some message");
this.Close();
}
I would like to know if there is a way of adding a global exception handler for all my child forms (I do have a base form they inherit from) that can catch exceptions and close the child form without closing the entire application.
This way if a developer "forgot" to add the try catch block on an event, it does not bomb the entire application.