Debug.WriteLine shows nothing

On Menu > tools > options > debugging > General:

  • Ensure "Redirect all output window text to the immediate window" is NOT checked

On Project Properties > Build:

  • Configuration: Debug
  • "Define DEBUG constant" is checked
  • "Define TRACE constant" is checked

On the Output window:

  • Show output from: Debug
  • Right-click in the output window and ensure "Program output" is checked

There are two likely causes for this behavior

  • The application is being compiled in Release mode and the Debug.WriteLine call is not in the final program
  • There is no trace listener in the program and hence nothnig to output the message

The easiest way to diagnose this is to change the code to

#if DEBUG
Console.WriteLine("the message");
#endif

If it prints then you have an issue with the trace listeners, else you're compiling in Release

Tags:

C#

Debugging