Application exception handling

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When my .Net WinForms application encounters an unhandled exception it
presents the dialog box that offers the user a 'Continue' option. I would
rather have the system present the error information and then quit the
application. Is there any way to do this?
 
Hi George,

Take a look at Application.ThreadException

public static void Main()
{
Application.ThreadException += new ThreadExceptionEventHandler(myHandler);
Application.Run(new Form1());
}

private void myHandler(object sender, ThreadExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message);
Application.Exit();
}
 
Back
Top