Have you by any chance redirected output to 'Immediate Window' in 'Debug->Options...'?
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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).
Have you by any chance redirected output to 'Immediate Window' in 'Debug->Options...'?
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?
Best Regards,
Tianyu
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
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].
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