Export (0) Print
Expand All

Diagnostic Messages in the Output Window

You can write run-time messages to the Output window using the Debug class or the Trace class, which are part of the System.Diagnostics class library. Use the Debug class if you only output in the Debug version of your program. Use the Trace class if you want output in both the Debug and Release versions. For more information, see System.Diagnostics Namespace.

The Trace and Debug classes provide the following output methods:

  • Various Write methods, which output information without breaking execution. For more information, see Debug Class and Trace Class. These methods replace the Debug.Print method used in previous versions of Visual Basic.
  • The Assert method, which breaks execution and outputs information if a specified condition fails. By default, the Assert method displays the information in a dialog box. For more information, see Assertions in Managed Code.
  • The Fail method, which always breaks execution and outputs information. By default, the Fail method displays the information in a dialog box. For more information, see Debug.Fail and Trace.Fail.

In addition to any information you output, the Output window displays the following:

  • The names of any modules the debugger has loaded or unloaded.
  • Information about any exceptions that are thrown.
    Note   If you call a Trace or Debug method from the Immediate window the output appears in the Immediate window rather than the Output window. For more information, see Immediate Mode, Command Window.

See Also

Output Window | Instrumentation Techniques (Debug and Trace) for the .NET Framework | Introduction to Instrumentation and Tracing | Debugging Visual C# and Visual Basic Projects | Debugging Managed Code

Show:
© 2014 Microsoft