Home Page

Debugging your C# program consists of monitoring the execution of the source code as the program is running.  Visual Web Developer has a debugger full of useful features.  The main point of debugging your source code is to determine whether or not it is behaving the way that you expected when you programmed it.  Not only can you go through the code to find problems or fix bugs, but you can also use the debugger to validate that the code is behaving exactly as you had intended it.  This is especially useful in more complicated blocks of code or blocks of code that rely on external resources to make a decision.  A good example is with database programming, where you may not have any idea ahead of time what the data will look like ahead of time, or whether certain fields will contain nulls, so you can use the debugger as your program runs to walk through different scenarios.  I want to make the point that the debugger is not just for situations where something is broken and you can use it for so much more than that.

Using the debugger is very easy.  You first need to determine what part of your program you want to examine.  Then you choose a line of code that you want the debugger to stop at and set what is called a “breakpoint”.  A breakpoint is a line of code in your program that the .NET engine knows to stop at when the program is running.  When the program actually runs, the .NET engine will stop the program at the breakpoint, minimize the web browser and open up the code editor window at the line where the breakpoint resides.  The breakpoint line will be highlighted by the debugger so that you know the program has stopped there.

Once the debugger has stopped at the breakpoint, you can use the debugger to do a number of things.  You can look at the values of the variables in your code by placing the cursor directly over the variable in the code.  The debugger also lists all the variables in your code inside the Locals window and you can use the to see the values of the variables as well.

To move to the next line of code you must use the Step Over button in the toolbar or press the F10 key.  You can keep stepping over each line of code and examine how the program is behaving.  If you want to stop debugging and go back to running the program just press the play button which will have the tooltip of “Continue” when the debugger is running.  All of the debugger functions such as Step Over and Continue are also available from the Debug menu.  Click here to see a sample video demonstrating how to use the debugger.

"Want the secret resource that beginning web programmers don't normally have access to? Want to start practicing with ASP.NET quickly and easily?"

Jump start your ASP.NET learning in a matter of minutes
Practice hands on with fully functional sample ASP.NET web sites
Master the most common ASP.NET programming techniques
Have tons of fun learning interactively
Improve at your own pace from the comfort of your computer

Click below to get started within minutes...
You too can MASTER ASP.NET Web Development Techniques

1 Comment »

  1. Thanks Ted, with this stuff, you make me the debugger idea more friendly!

    Comment by gianted — August 27, 2009 @ 6:26 am

RSS feed for comments on this post. TrackBack URL

Leave a comment