One of the things I loved about VB6 is that you had the ability to tell the development environment to break on all errors regardless of what error handling you had set up. Is it possible to do the same thing in VS2008 so that the debugger will stop on any error even if it happens inside a try-catch statement?
The problem is particularly hard when you are processing a file with say 500 records and it is failing on one of them - who knows which one - You don't want to modify the code so that your for counter is initialized outside that for loop - that is sloppy long-term. You just want the debugger to know to stop because of some setting you put somewhere.
Tell the debugger to break when an exception is thrownIn the Exception Settings window (Debug > Windows > Exception Settings), expand the node for a category of exceptions, such as Common Language Runtime Exceptions. Then select the check box for a specific exception within that category, such as System.
Note: you can uncheck Break when this exception type is thrown directly in the exception handler and continue debugging (press F5 ). Visual Studio will add this exception type to the Exception settings and will remember that it shouldn't break on this exception again.
You can open the exception settings window by navigating from Debug -> Windows -> Exception Settings. With Visual Studio 2017, it has some additional features and which is quite useful. You can now set the condition on the exception in the Exception settings Windows.
The try-catch statement consists of a try block followed by one or more catch clauses, which specify handlers for different exceptions. When an exception is thrown, the common language runtime (CLR) looks for the catch statement that handles this exception.
Yes, go to "Debug" menu, select "Exceptions...", check "Thrown" for "Common Language Runtime Exceptions"
Sure, press Ctrl-Alt-E to bring up the exceptions window and tick the Thrown checkbox on Common Language Runtime Exceptions
That will stop the execution, open the source code where the exception was thrown, and tell you with a message window what error it is, pointing at the line it was thrown.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With