VisualStudio: no debug output

I’m trying to debug a C# application. The method:

System.Diagnostics.Debug.WriteLine("something");

should do the work, but in the Output window (set to “debug” and with all the options activated) I can’t see a single line I’m trying to write. Any idea?
Thanks

EDIT:
I’m using VS2008

There’s an option under Tools-Options-Debugging-General, Redirect all Output Window text to the Immediate Window. Make sure that’s disabled. However, by default it isn’t, so I doubt that’s your issue. You can also just check your Immediate Window to see if it’s outputting there.

You might also want to try resetting all your environment settings. (Tools – Import and Export Settings – Reset all settings.)

Also worth checking – right-click in the output window, and ensure “Program output” is checked.

Have you checked to make sure you’re compiling in Debug mode? If you compile in Retail / Release mode you will see this behavior.

You should be able to see this information on Visual Studio’s toolbar. There will be a combo box which will say Release or Debug. If it says Release, switch it to Debug.

In certain profile settings, this combo box will not be visible by default. You’ll have to access it through the project properties page. It will be on the build / compile tab.

Apart from the suggestions above, take a look at the project properties by right-clicking on the project name and selecting Properties. Once you have that up click on the Build tab and then the Advanced button in the lower right. Once you have the Advanced window up, take a look at the Output section and the Debug Info: setting. When you are in debug mode this should be set to full.

I had the same issue, got debug to show by selecting:

Debug -> Windows -> Output

However, my output is still now showing, so I guess vs will hide Debug until there is actual data being written out.

Also, make sure that your Output window is set to show “Debug” output instead of something else like “Build” output.

You should see it loading all the required assemblies in the “Debug” output.

You need to explicitly add the system’s Console as a TraceListener in order for the output to appear in the console. According to Microsoft’s documentation, this code should do the trick. This is C# code, but the link I provided contains examples for the other .NET languages.

using System;
using System.Data;
using System.Diagnostics;

class Test
{
    static void Main()
    {
       Debug.Listeners.Add(new TextWriterTraceListener(Console.Out));
       Debug.AutoFlush = true;
       Debug.Indent();
       Debug.WriteLine("Entering Main");
       Console.WriteLine("Hello World.");
       Debug.WriteLine("Exiting Main"); 
       Debug.Unindent();
    }
}

“Enable the Visual Studio hosting process” under project properties -> Debug solved the issue for me.

IF you use shortcuts, make sure you press F5 to Start Debugging mode (not Ctr+F5).

F5 Starting Debugging

CTRL+F5 Starting Without Debugging

I just ran into this issue with Visual Studio 2010 and 2017 and this is what I did to get it to work and I have no explanation as to why it now works.

What I did to get it work.
I created a new Windows Form project and added a button which when pressed executed Console.WriteLine(“Test”). I saw “Test” in the Output Window. I then loaded my real project and added a button to execute Console.WriteLine(“Test”) and now it produced output. Further Console.WriteLine statements worked from then on.

In my project in Visual Studio 2017, output appears in the Immediate Window

If all else fails, try the old restart of Visual Studio. Worked for me.

Your debug output might be being sent to a new command prompt external to Visual Studio which opens up when you start debugging. It’s easy to miss this if you are totally engrossed in what VS is doing!

How about opening the project properties and going to Linker->System->SubSystem and changing it to Console? Mine was set to Windows but still it doesn’t show up in the Output pane like normal but at least you may be able to see something.

My problem was, output windows was open, but when I started debugging, it disappeared immidately.
I found that, when is debugging, I have to show it again from View->output or Ctrl+W,O.
Then it will stay there.

Leave a Comment