I have an unhandled exception event in the ApplicationEvents area of my program, but it never gets called when I do get unhandled exceptions. Is there a trick to making this work?
Printable View
I have an unhandled exception event in the ApplicationEvents area of my program, but it never gets called when I do get unhandled exceptions. Is there a trick to making this work?
It should capture any exception in your app that wasn't caught/handled by another exception handler somewhere.
Did you check your code to make sure you don't have a try block around some main entry point in your code that is supressing the error instead of letting it bubble up to the application framework unhandled exception handler?
"The Visual Basic compiler prevents applications that are built for debugging from raising this event, to allow a debugger to handle the unhandled exceptions. This means that if you are testing your application by running it under the Visual Studio Integrated Development Environment debugger, your UnhandledException event handler will not be called. For more information on building applications for debugging, see /debug (Visual Basic)."
Hey thanks, I didn't know that. So it should work fine in my compiled app?
just run your app in the IDE with ctrl+F5 instead of just F5/play button, and it should run without debugging.
That was the problem. When I compiled & ran the app it caught the unhandled exception. Is there any limitations on what code can be run under that event? Also, is it possible to get the details of the exception? (like the stack trace)
OK, I found e.Exception.StackTrace & e.Exception.Message
You can also set e.ExitApplication to toggle if the app should close, or if it should try to continue on (like if you reset everything back to scratch and start up over on an unhandled exception, versus the app just closing and the user needing to reopen the app)
Thanks guys...