Debugging Techniques

Team Fly 

Page 231

the Common Language Runtime Exceptions section of the Exception window. You can choose an exception in the upper window of the dialog box and specify how the Debugger will handle it in two frames near the bottom of the dialog box. The options in the upper frame determine how the debugger will react to an exception as soon as it's thrown and before your code is given a chance to handle it through the appropriate exception handler. The options in the lower frame determine how the debugger reacts when an unhandled exception is thrown. The options you set in the two frames affect the selected exception, and you can handle different types of exceptions differently. The option ''Break into the debugger" breaks the execution of the program as if there were a break point on the statement that caused the exception. The option "Continue" allows the application to continue its execution. If the statement that threw the exception is in a structured exception handler, the handler will be activated. The "Use parent setting" option handles the exception as it would handle an exception of the parent category (if there is one). Notice that you can add your custom exceptions to the list of exceptions with the Add button.

image

FIGURE 9.3 The Exceptions dialog box

If an error occurs in an error handler's code, you can retrieve the statement that caused the initial error with the InnerException property of the Exception object.

Debugging Techniques

In addition to handling user mistakes, you must also handle your own mistakes. How many times did you write code that contains no syntax errors, executes fine, but doesn't produce the correct results? It's happened to everyone who has written some serious code. Your code contains logical errors, which you must identify and then fix. When you're dealing with logical errors, you must step back and reevaluate your algorithm. Make sure that you're using the proper steps to get to the desired result. The algorithm is usually correct, but in most cases it's not implemented correctly.

Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net