I have a simple WinForms application that is used to enter test cases. Since I upgraded this application to .NET 4.0 and added a new tab to the tab control for XML validation using the XSD scheme, the application accidentally crashed. I could not reproduce the exception.
The error my QA guy is getting is a generic Windows message:
TestCaseViewer has encountered a problem and needs to close. We regret the inconvenience.
To try to get to the real error, I added the following code at the beginning of the main program method:
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += Application_ThreadException;
Event handlers are as follows:
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { try { MessageBox.Show(e.Exception.ToString(), @"Thread Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { Application.Exit(); } } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { var ex = (Exception)e.ExceptionObject; MessageBox.Show(ex.ToString(), @"Unhandled Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { Application.Exit(); } }
Unfortunately, this did not help, and everything that happens continues to work in such a way as to generate an unhandled error that bubbles up to the OS.
Can anyone give me any other ideas on throwing this exception?
exception winforms unhandled
Loathian Feb 19 '11 at 5:23 2011-02-19 05:23
source share