static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { ExceptionViewer viewer = new ExceptionViewer(e.Exception); viewer.ShowDialog(); }