Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing to output window of Visual Studio

I am trying to write a message to the output window for debugging purposes. I searched for a function like Java's system.out.println(""). I tried Debug.Write, Console.Write, and Trace.Write. It does not give an error, but it does not print anything either.

"Define DEBUG constant" and "Define TRACE constant" options are checked.

Menu ToolsOptionsDebugging"Redirect all Output Window text to the Immediate Window" option is not checked.

Configuration: Active (Debug)

Note: I created a project with the wizard as "Windows Forms Application" if relevant. I have no idea where to look.

like image 481
previous_developer Avatar asked Feb 27 '12 14:02

previous_developer


People also ask

How do I get the output window in Visual Studio?

To display the Output window whenever you build a project, in the Options dialog box, on the Projects and Solutions > General page, select Show Output window when build starts.

How do I turn on output in Visual Studio?

Go to Tools, Options, Projects And Solutions, and uncheck Show Output Window when Build Starts.


2 Answers

Add the System.Diagnostics namespace, and then you can use Debug.WriteLine() to quickly print a message to the output window of the IDE. For more details, please refer to these:

  • How to trace and debug in Visual C#
  • A Treatise on Using Debug and Trace classes, including Exception Handling
like image 199
Bhargav Bhat Avatar answered Sep 29 '22 23:09

Bhargav Bhat


This will write to the debug output window:

using System.Diagnostics;  Debug.WriteLine("Send to debug output."); 
like image 43
veight Avatar answered Sep 30 '22 00:09

veight