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 System.Diagnostics namespace. Unless otherwise stated, the types mentioned in this chapter all exist in either the System or System.Diagnostics namespaces.

    Part II: Programming with the .NET Framework
    Part IV: API Quick Reference