1

I'm a super-beginner coder and trying to follow a training video on C# in Visual Studio 2015. The tutorial has me do a new Visual C# project as a Console Application. When I run my code using Ctrl+F5, it launches my code in the console as expected, but the Output --> Show output from build window is completely empty.

I've scoured this site and others for a solution. These are my current VS2015 settings, I've tried changing these with no success:

  • Show Output window when build starts is CHECKED
  • Redirect all Output Window text to the Immediate Window is UNchecked.

This is the code, verbatim what is shown in the tutorial:

using System;

namespace Hello
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World");
        }
    }
}

When the same code is run in the tutorial, the resulting output appears immediately in the Output window:

1>------ Build started: Project: Hello, Configuration: Debug Any CPU ------
1>  Hello -> c:\users\[name]\documents\visual studio 2015\Projects\Hello\Hello\bin\Debug\Hello.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

I can see my Output window and I expect to receive this, but I get nothing. First time using Visual Studio, what am I missing?

  • There is a related post with good explanations [here](https://stackoverflow.com/a/46925335/1911064). By default, `Console.WriteLine()` does only write to the console window, rather than to the `Output` window. Consider using `Trace` or `Debug`. – Axel Kemper Aug 20 '19 at 21:30
  • [This post](https://stackoverflow.com/questions/5301232/seeing-the-consoles-output-in-visual-studio-2010?rq=1) might also be helpful. – Axel Kemper Aug 20 '19 at 21:37
  • From the post @Axel_Kemper has pointed out.. here is what you are looking for.. "You can use the System.Diagnostics.Debug.Write or System.Runtime.InteropServices method to write messages to the Output Window." – Señor CMasMas Aug 20 '19 at 22:03
  • @AxelKemper the second post you linked to contained a solution. Updated this post with an answer. Thank you sir. – CSharphedder Aug 21 '19 at 15:35

1 Answers1

0

Prior to adding Console.Read(); at the end of my code, running the code would launch the console with the following output:

Hello, World Press any key to continue...

But, the build output window in VS remained blank as originally described.

After adding Console.Read();, the output in console no longer contained

Press any key to continue...

However, the build output in VS now displays what is expected as described in Original Post.

If I then remove Console.Read();, reverting back to my original code, the console output is back to original, and the VS build output window still gives expected output...

I suspect that, using Visual Studio for the first time, it had never been directed to write to the Output window, which was accomplished here with Console.Read(); and should do this going forward...

Link to solution I used:

https://stackoverflow.com/a/5301276/11953574