I\'m working on a rather large project, and its unlikely will catch everything. I\'ve found the event that notifies me of unhandled exceptions, however I haven\'t found a wa
This is what we did.
static void Main() {
try
{
SubMain();
}
catch (Exception e)
{
HandleUnhandledException(e);
}
}
private static void SubMain()
{
// Setup unhandled exception handlers
AppDomain.CurrentDomain.UnhandledException += // CLR
new UnhandledExceptionEventHandler(OnUnhandledException);
Application.ThreadException += // Windows Forms
new System.Threading.ThreadExceptionEventHandler(
OnGuiUnhandledException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
// CLR unhandled exception
private static void OnUnhandledException(Object sender,
UnhandledExceptionEventArgs e)
{
HandleUnhandledException(e.ExceptionObject);
}
// Windows Forms unhandled exception
private static void OnGuiUnhandledException(Object sender,
System.Threading.ThreadExceptionEventArgs e)
{
HandleUnhandledException(e.Exception);
}