Riley asked this 3 months ago

Debug.WriteLine not working in VS 2017

On a Windows Forms application that i am developing with C# on Visual 2017, trying to write a string variable to the output window as below.

using System.Diagnostics;

Debug.WriteLine(MyStringVar);

but nothing appears in the output window when i run the code in debug mode. 

tried this instead:

Debug.WriteLine("Test"); 

Still nothing.


Best Answer by gen2018 3 months ago

Go to Tools -> Options -> Debugging -> General 

and look for the option Redirect all Output Window text to Immediate Window.

If that option is checked then the output from Debug.Writeline will be displayed on the Immediate window.  You can uncheck this option to view everything on Output window.

To open Immediate Window click Debug -> Windows ->Immediate or use the shortcut CTRL+G.

Riley 3 months ago
Thanks for the quick answer gen. that solved it.