Home > Articles > Programming > Windows Programming

Visual Studio .NET Debugging Environment

  • Print
  • + Share This
In this sample chapter, Brian Peek examines all the features available for debugging in the Visual Studio .NET IDE, how to use them, and where each one is applicable for the problem you might be trying to conquer.
This sample chapter is excerpted from Visual Studio .NET Debugging Environment, by Brian Peek.
This chapter is from the book

This chapter is from the book

The ASP script debugger that is integrated with the new Visual Studio .NET IDE is, without a doubt, one of the greatest enhancements to debugging from the previous versions of ASP. Unlike trying to debug traditional ASP pages in Visual Interdev, this actually works right out of the box!

In this chapter, you will be looking at all the features available for debugging in the Visual Studio .NET IDE, how to use them, and where each one is applicable for the problem you might be trying to conquer. This will all be accomplished by building a project from scratch in the IDE, so we recommend creating the project on your own as it is done in this chapter.

Introduction to Features

Let's start out by taking a look at the most important features of the Visual Studio .NET IDE debugger. You will take a detailed look at all of these as the chapter progresses. Many of these features have existed in the Visual Studio 6.0 IDEs; however, not all were previously available when debugging traditional ASP pages in Visual InterDev.

Call Stack

The call stack enables you to display the list of functions currently called. As the name implies, this can be imagined simply as a stack. (As functions are called from within function, which, in turn, are called from within functions, a stack is created.) With the call stack viewer, you can look at this stack and jump forward and backward into the stack to debug at any point in the chain. Figure 7.1 shows the call stack in action.

Figure 7.1 The call stack window.

Command Window

If you have used the Visual Basic IDE previously, the command window will be quite familiar to you. The command window enables you to execute program statements separately from the running program. For example, if you want to set a variable equal to a new value, or if you want to print the value of a variable, or even if you want to create an object and call some methods on it, you can do it from this window. Figure 7.2 shows how the command window can be used.

Figure 7.2 The command window.

Breakpoints

Breakpoints enable you to stop the execution of a program at a defined point either in all instances or based on a certain set of criteria. The easiest way to set a breakpoint is to click in the gray left margin next to the line where you want to stop. The IDE drops a red "dot" in the margin; when you start the program in debug mode, it stops at that specified position. By popping up the breakpoint window from the debugging windows at the bottom of the screen, you can see all breakpoints currently set in the system. Figure 7.3 shows an example of the breakpoint window.

Figure 7.3 The breakpoint window.

Watch Window

The watch window can be used to watch the contents of a variable or series of variables. This window also enables you to change the value of a variable, which can be quite useful in debugging applications. You can see an example of the watch window in Figure 7.4.

Figure 7.4 The watch window.

Tracing

Tracing simply enables you to write out a series of text messages as the program is executing so that you can see what is happening at any point during the program's life cycle. This can be very useful in creating a log of events that can be inspected later to ensure that the program is operating as you expect in all aspects. Figure 7.5 shows an output from a Debug.Trace statement in the output window.

Figure 7.5 Tracing and the output window.

  • + Share This
  • 🔖 Save To Your Account