Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug.Writeline is Not printing anything

Tags:

c#

debugging

VS 2010 Pro, C#, WinForms: at the very beginning of my method I am saying Debug.Writeline("entering method blah"); then somewhere inside this method I am putting some breakpoints and run the program. so I see that execution is stopped at those break points, so it is here! but if I search the Output->Debug combobox mode and also Immediate window I cannot find the message I has written for Debug.Writeline anywhere.

I also tried that heck box setting in Debug options that says "Redirect all output to Immediate window"....did not help either.

like image 914
Bohn Avatar asked Sep 19 '11 21:09

Bohn


People also ask

How do I enable debug WriteLine?

You have to select "Debug" AND make sure that you "Start Debugging". This can be reached by pressing F5 . Also the Console. WriteLine will only display messages when building as "Release" in your Output window.

What does debug WriteLine do?

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

What is debug print in C#?

Writes a message followed by a line terminator to the trace listeners in the Listeners collection. public: static void Print(System::String ^ message); C# Copy.


4 Answers

Discussed already in the comments, but I wasn't sure until discussing it there. However:

  • calls to Debug.Whatever(...) are typically marked with [Conditional("DEBUG")], meaning they require the DEBUG symbol to be defined, otherwise those calls are not compiled
  • a default project has DEBUG and TRACE defined for the "Debug" profile, and TRACE for the "Release" profile
  • however, you can disable the DEBUG symbol via a checkbox in "project properties"

So; go to project-properties, and ensure the DEBUG symbol is defined (or not) as appropriate for your needs (for any-and-all profiles that exist in your project).

like image 176
Marc Gravell Avatar answered Oct 21 '22 02:10

Marc Gravell


Make sure you press F5 to Start Debugging mode (not Ctr+F5).

F5 Starting Debugging

CTRL+F5 Starting Without Debugging

enter image description here

like image 31
Serge Voloshenko Avatar answered Oct 21 '22 02:10

Serge Voloshenko


if Debug does not print anything (and you can't breakpoint on it) : you also have to check "TRACE" in project properties.

like image 1
Poppyto Avatar answered Oct 21 '22 01:10

Poppyto


If there is still no output after all, check the message types that are enabled for the output window:

  1. Right-Click inside the content area of the Output-Window.
  2. Make sure "Program Output" is selected for example. (It should look like the screenshot)

enter image description here

like image 1
spikey Avatar answered Oct 21 '22 02:10

spikey