Debug VS.NET Applications
Solve debugging issues by using the VS.NET IDE debugging tools effectively.
by Nancy Folsom and Kathleen Dollard
September 2002 Issue
Technology Toolbox:VB.NET, C#
The best way to approach debugging depends on the problem, language, and your experience using the language. The best approach might change as you narrow down a problem's cause. In this article, we'll show you how to use the Visual Studio .NET IDE debugging tools to solve common problems.
VS.NET includes a wealth of debugging tools—too many to discuss in detail here. Some highlights include the ability to set breakpoints and watch points; to step through code as it executes; to view and change variables and values; to navigate through the callstack of executing programs, methods, and events; and to include diagnostic debug statements. VS.NET also includes powerful debug and trace classes, and the ability to do remote debugging and to attach to running processes. You can debug across languages and drop down into an assembly-level view of your application, and, to top it off, you can control debugging programmatically.
More than one approach might be successful in solving a problem, but most successful approaches involve several rules of thumb (see the sidebar, "Debug Successfully"). Get started with your debugging efforts by downloading the Visual C# Factory example code project; it contains a simple but common logic error (see Listing 1). The program should fill a shipment. When the code runs, an error dialog is displayed that says, "An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Factory.exe. Additional information: Index was outside the bounds of the array." The error message doesn't say which array, or even what part of the code, is having the problem. So, you should elect to "Break." Once suspended, the IDE's debugging components help narrow down the source of the problem.
Back to top
|