1 / 9

Lecture 3 Debugging and Error Handling

Lecture 3 Debugging and Error Handling. Debugging Techniques. Outputting Debugging Information

cooks
Download Presentation

Lecture 3 Debugging and Error Handling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 3 Debugging and Error Handling

  2. Debugging Techniques

  3. Outputting Debugging Information Writing text to the Output window at runtime is easy. You simply replace calls to Console.WriteLine() with the required call to write text where you want it. There are two commands you can use to do this: Debug.WriteLine() Trace.WriteLine() These commands function in almost exactly the same way, with one key difference — the # rst command works in debug builds only; the latter works for release builds as well. In fact, the Debug.WriteLine() command won’t even be compiled into a release build; it just disappears. These require the inclusion of using System.Diagnostics;

  4. Using Tracepoints To demonstrate tracepoints, you can use them to replace the debugging commands in the previous example. The process for adding a tracepoint is as follows: 1. Position the cursor at the line where you want the tracepoint to be inserted. The tracepoint will be processed before this line of code is executed. 2. Right-click the line of code and select Breakpoint ! Insert Tracepoint. 3. Type the string to be output in the Print a Message text box in the When Breakpoint Is Hit dialog box that appears. If you want to output variable values, enclose the variable name in curly braces. 4. Click OK. A red diamond appears to the left of the line of code containing a tracepoint, and the line of code itself is shown in red.

  5. Breakpoints A breakpoint is a marker in your source code that triggers automatic entry into break mode. Breakpoints can be configured to do the following:

  6. Assertions

  7. Monitoring Variable Content

  8. Error Handling

More Related