Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug.WriteLine skipped while debugging

Tags:

c#

debugging

I am writing a simple C# Code, but the parts where Debug.WriteLine(".."); appear, get skipped. For instance:

WebClient wc = new WebClient();

        wc.Encoding = System.Text.Encoding.GetEncoding("ISO-8859-1");
        wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(SearchWordsDownloaded);

        Debug.WriteLine("test");
        wc.DownloadStringAsync(new Uri("SomeURL"));

Why is that happening?

like image 385
QKL Avatar asked Oct 06 '12 18:10

QKL


People also ask

How do I enable debug WriteLine?

WriteLine calls may not display in the output window if you have the Visual Studio option "Redirect all Output Window text to the Immediate Window" checked under the menu Tools → Options → Debugging → General. To display "Tools → Options → Debugging", check the box next to "Tools → Options → Show All Settings".

What does debug WriteLine do?

Writes information about the debug to the trace listeners in the Listeners collection.

What is the difference between debug and trace?

Debug is going through the code flow during run time where as tracing is giving details of execution plan, process timing details. Debug and trace enables you to monitor the application for errors and exception with out VS.NET IDE. In Debug mode compiler inserts some debugging code inside the executable.

How do I show the console WriteLine in Visual Studio?

In Visual Studio uppermost menu choose Debug > Windows > Output. It shows all Console. WriteLine("Debug MyVariable: " + MyVariable) when you get to them.


1 Answers

I was seeing this - Debug.WriteLine() statements being jumped over for a debug build with the debugger attached. Not sure why but the DEBUG compilation symbol was not being set. Go to the project properties page, build section, and within the 'Conditional compilation symbols' field enter 'DEBUG' (without quotes). That caused the debugger to start entering Debug statements again.

like image 145
redcalx Avatar answered Oct 07 '22 00:10

redcalx