Diagnostics. Debug. WriteLine will display in the output window ( Ctrl + Alt + O ), you can also add a TraceListener to the Debug.
"Writes information about the debug to the trace listeners in the Listeners collection." c# visual-studio.
WriteLine(String) Writes a message to the trace listeners in the Listeners collection.
In Visual Studio uppermost menu choose Debug > Windows > Output. It shows all Console. WriteLine("Debug MyVariable: " + MyVariable) when you get to them. Set breakpoint before, debug, and then use F11 to step through code line by line.
Check following items -
DEBUG
mode is selected while debuggingDebug
option is selected in Output window -
Debug.AutoFlush = true
at the beginning of codeReference for Point #5 (Read the comment, It worked for that guy)
For me, this solved the problem:
System.Diagnostics.Trace.WriteLine("whatever");
(using Trace
instead of Debug
)
In your app.config file, make sure you don't have a <clear/>
element in your trace listeners.
You will effectively be clearing the list of trace listeners, including the default trace listener used for Debug statements.
Here's what this would look like in your app.config file:
<system.diagnostics>
<trace>
<listeners>
<!-- This next line is the troublemaker. If it is there delete it-->
<clear/>
</listeners>
</trace>
</system.diagnostics>
For me, I needed to do this to solve the problem:
1. Open the project's property page
2. Under Build tab, check "Define DEBUG constant" and "Define Trace constant"
Voila!
I had the same problem. Using Trace.WriteLine and checking "Define DEBUG constant" did not work for me.
I noticed that the output messages were found in Immediate window, instead of Output window.
Then I unchecked "Redirect all Output Window text to the Immediate Window" option in tools and solved my problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With