Chapter 9: Debugging Techniques

Chapter 9
Debugging Techniques
  • Compiling Code Conditionally
  • Tracing the Stack
  • Using the Trace and Debug Classes
  • Debugging with Visual Studio .NET

This chapter examines the debugging and diagnostic techniques that you can use when developing with Microsoft Visual C# .NET. The C# language and the Microsoft .NET Framework include a number of features that not only simplify debugging but also make it extremely easy to take advantage of sophisticated diagnostic techniques. For example, with Visual C# .NET, it’s easy to send debug and trace messages to the event log, a disk file, or the console. Adding this functionality requires less than a dozen lines of Visual C# code. To achieve similar functionality using the C language would require a significantly larger effort, probably a thousand lines or more.

With Visual C#, you can also take advantage of classes that enable you to inspect and display the call stack. (See the section “Using the Call Stack,” later in this chapter.) This information can be invaluable during debugging. This chapter also discusses how to create a custom trace listener to display output messages as XML and closes with a section that describes the debugger integrated into Microsoft Visual Studio .NET.

Part III: Programming Windows Forms