Reputation: 47
My c# program implements a unhandledExceptionEventHandler. Still, one of the libraries that I use throws up a NotImplemented exception. Windows promptly throws up a dialog box whether I want to continue or exit. How do I catch this exception (so that I can exit without prompting the user?)
Upvotes: 2
Views: 1615
Reputation: 334
If you are working on VS2010, simply go to the Debug
menu and hit Exceptions...
. Now check every exception on Thrown
. Run your program again from IDE on Debug mode. Now your program will stop on every exception. You will be able to identify what's happenning when you are exiting.
Upvotes: 1
Reputation: 13529
It is more straightforward to wrap your entry points with try ... catch
than to use the handler, but anyway. If you are debugging from an IDE, those dialog boxes correspond to the beginning of processing of the exception, whereas the UnhandledExceptionEventHandler
only gets a chance to execute after the stack has been completely unrolled, at the end of the same process, and when there is nothing left on that unfortunate thread for debugging. You should be able to disable the unwanted dialog in your IDE (for example, like this).
Upvotes: 0