VS 2019 Console.Writeline - Output not present in Output window

Jay Jaeger 31 Reputation points
2021-02-20T23:46:51.5+00:00

So, I am used to using Console.Writeline during development to generate debugging output (and then remove them and comment them out when no longer needed). My app is a C# Windows Forms App (not a WPF app). But the output is simply not appearing in the Output window (Show output from: Debug) where I was expecting it (and where I see it in VS 2017. What might I have overlooked? (I created a new little app from the template just as a test - and it doesn't show up on that one, either).

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,573 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
935 questions
{count} votes

9 answers

Sort by: Most helpful
  1. Maybecompletelyw_0 276 Reputation points
    2021-02-21T07:29:55.23+00:00

    Have you by any chance redirected output to 'Immediate Window' in 'Debug->Options...'?

    70309-output.jpg

    2 people found this answer helpful.

  2. Tianyu Sun-MSFT 27,106 Reputation points Microsoft Vendor
    2021-02-22T06:10:02.703+00:00

    Hi @Jay Jaeger ,

    Welcome to Microsoft Q&A forum.

    Typically, Console.WriteLine() writes to Console, since the Output Window is not console, we can use System.Diagnostics class library(the Debug class or the Trace class) to send messages to the Output window.

    But under certain circumstances, Console.WriteLine( ) also works and the message will appear in the Output window. I tested on my side and I noticed that the Console.WriteLine( ) did show the message in my Output window. If you did the same thing like I tested but this issue remains, I suggest you start Visual Studio 2019 in Safe Mode(run devenv /SafeMode in Developer Command Prompt for VS 2019) and set the breakpoints for the “comment” and start debugging, press Step Into(F11) to see if VS hit the breakpoint and will the message in Output windows appear?

    70415-debug.png

    Best Regards,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    2 people found this answer helpful.
    0 comments No comments

  3. Jay Jaeger 31 Reputation points
    2021-02-22T16:31:12.167+00:00

    When I changed my message from Console.WriteLine() t Debug.WriteLine(), yes, the message did appear in the Output window, so this was NOT a matter of the code not reaching that point. The messages from Console.WriteLine() are not appearing. This worked fine in VS 2017 (in a different application. I even made a dummy application (much like what you have above) and put a Console.Writeline() right at the beginning after InitializeComponent, and the output from Debug.WriteLine() is there, but not Console.WriteLine().

    public Form1()
    {
    InitializeComponent();

            Debug.WriteLine("Hello Debug!");
            Console.WriteLine("Hello Console!");
    
        }
    

    Results in:

    'WindowsFormsApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.12\System.ComponentModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

    Hello Debug!

    'WindowsFormsApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\3.1.12\Microsoft.Win32.SystemEvents.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'WindowsFormsApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.12\System.Buffers.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
    'WindowsFormsApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\3.1.12\System.Collections.NonGeneric.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

    VS 2019 Community 16.8.5

    1 person found this answer helpful.

  4. Jay Jaeger 31 Reputation points
    2021-02-23T14:58:07.03+00:00

    I have several projects in VS 2017 where Console.WriteLine() works the way I expected. In VS 2019, it does not work. I will report it as a problem. The VS 2019 application template I used was "Windows Forms App (.NET)" [as opposed to Windows Forms App (.NET Framework) or WPF App templates].

    1 person found this answer helpful.
    0 comments No comments

  5. Jay Jaeger 31 Reputation points
    2021-02-23T20:37:42.927+00:00

    Reported to day, in a thread what was first opened on this same issue on October 26, 2020:

    https://developercommunity.visualstudio.com/t/VS2019-ConsoleWriteline-in-output-windo/1233073

    1 person found this answer helpful.
    0 comments No comments