Section 1
Debug and trace a .NET Framework application by using the System.Diagnostics namespace.
- Debug class and Debugger class
- Trace class, CorrelationManager class, TraceListener class, TraceSource class, TraceSwitch class, XmlWriterTraceListener class, DelimitedListTraceListener class, and EventlogTraceListener class
- Debugger attributes
Summary
The Debug class exposes properties and methods to help you debug your code. It exposes methods like Write, WriteLine, WriteLineIf, WriteIf and Assert for displaying methods. It also exposes a Listeners collection which monitor the output.
The Debugger class communicates with the debugger programmatically. With it you can log message, check if the debugger is attached or even call out a break point.
The Trace Class is just like the debugger but also exists in release builds. The ListnersCollection is the collection of TraceListener objects monitoring the output.
The Trace Source Class is new to .Net. It enables you to configure a group of Listeners through configuration and then turn them on in the switches section of your configuration file. Each entry represents an instance of the TraceSwitch class. See the Resources for a better understanding of this.
The XmlWriterTraceListener, DelimitedListTraceListener, and EventlogTraceListener are all listeners that write output to different sources in different formats.
Debugger Attributes are used to give you control over what and how properties and method appear in the watches during debugging.
Other Resources & Links:
Debug Class
http://msdn2.microsoft.com/en-us/library/system.diagnostics.debug.aspx
Debugger Class
http://msdn2.microsoft.com/en-us/library/7kzs2ysh(en-US,VS.80).aspx
Trace Class
http://msdn2.microsoft.com/en-us/library/36hhw2t6(en-US,VS.80).aspx
Trace Source Class
http://msdn2.microsoft.com/en-us/library/hd7z6as6(en-US,VS.80).aspx
TraceSwitch Class
http://msdn2.microsoft.com/en-us/library/eb1fee91(en-US,VS.80).aspx
Tracing in .NET and Implementing Your Own Trace Listeners
http://www.15seconds.com/issue/020910.htm
DataTips, Visualizers and Viewers Make Debugging .NET Code a Breeze
http://msdn.microsoft.com/msdnmag/issues/04/05/VisualStudio2005Debugging/