1 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
2 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler);
3 Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
4