private static void Application_UnhandledException(object sender, UnhandledExceptionEventArgs e) { if (e.ExceptionObject != null) { Exception ex = (Exception)e.ExceptionObject; MessageBox.Show(ex.Message, "Application exception"); } }