Unhandled Exception in Winforms Application -
i have simple winforms app used enter test cases. ever since upgraded application .net 4.0 , added new tab page tab page control validating xml against xsd schema application has been randomly crashing. i've been unable reproduce exception.
the error qa guy receives generic windows message:
testcaseviewer has encountered problem , needs close. sorry inconvenience.
to try real error i've added following code beginning of main method of program:
appdomain.currentdomain.unhandledexception += currentdomain_unhandledexception; application.setunhandledexceptionmode(unhandledexceptionmode.catchexception); application.threadexception += application_threadexception;
the event handlers this:
static void application_threadexception(object sender, threadexceptioneventargs e) { try { messagebox.show(e.exception.tostring(), @"thread exception", messageboxbuttons.ok, messageboxicon.exclamation); } { 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); } { application.exit(); } }
unfortunately hasn't helped , whatever thowing error continues in way generates unhandled error bubbling os.
can give me other ideas trapping exception?
try adding following app.config
<runtime> <!-- following setting prevents host closing when unhandled exception thrown --> <legacyunhandledexceptionpolicy enabled="1" /> </runtime>
Comments
Post a Comment