Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main()
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
- AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
- Application.Run(new Form1());
- }
- static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- {
- MessageBox.Show(e.Exception.Message, "Unhandled Thread Exception");
- // here you can log the exception ...
- }
- static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- MessageBox.Show((e.ExceptionObject as Exception).Message, "Unhandled UI Exception");
- // here you can log the exception ...
- }
Advertisement
Add Comment
Please, Sign In to add comment