Chapter 19. Diagnostics
Even good applications sometimes have bad things happen to them. When things go wrong, it is important to detect this as soon as possible, and to gather information to aid in diagnosing the source of the problem. On the developer’s desktop, the tools for doing this include debuggers and profilers. However, once the application leaves the desktop, these tools are generally no longer available. Consequently, it becomes the application’s responsibility to perform this detection and information-gathering role.
Because providing integrated error handling and reporting is such a common need among applications, the .NET Framework provides a diverse set of facilities to monitor application behavior, detect runtime errors, inspect the application environment, report application status and integrate with debugging tools if available.
This chapter introduces the debugging and diagnostics support in the
.NET Framework, which is primarily contained in the
Unless otherwise stated, the types mentioned in this chapter all exist in
Logging and Assertion Facilities
Trace classes provide
error logging and assertion capabilities. These two classes are almost identical;
the main differentiator is how they are used. The
is used primarily in debug builds, while the
is used in both debug and release builds.
For error logging and assertion, make use of the
Debug and ...