To instrument an application, developers commonly use trace messages. By default, trace messages are displayed in the Output window. Trace messages are used for a variety of reasons but primarily for diagnostic purposes. Traces can validate program flow (often the cause of bugs). Trace messages can display the state of the application at different stages. You can display the values of objects, local variables, or other data throughout the lifetime of an application. Finally, trace messages are useful for tracking events, such as start, stop, and user-defined events.

Various classes in the Framework Class Library (FCL) support tracing. TraceSource is the primary tracing type. The TraceSource class is found in the System.Diagnostics namespace. ...

Get Programming Microsoft® Visual C#® 2008: The Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.