debug.writeline on compile

  • Thread starter Thread starter Smoke
  • Start date Start date
S

Smoke

Whats is the deal with Debug.WriteLine command...
I mean, in my programs, i usually add many of those commands to debug it while programming, and to be able to find bugs and things
easier, but, it is safe to leave those lines when u compile the program? or you are suposed to remove them?

Maybe the compiler delete that lines automatically when u compile the program, but that wont make much sense since inside VS.net the
program you launch is a compiled version.... so? debug.writeline will "run" all the time and will only output something if its
running inside the VS.net IDE? , if so, maybe there is any other way to "retrieve" those values? is it possible to read the
debug.writeline outputs running a program outside of the IDE ?

I would like if ppl can comment here what they know about this....
 
Smoke said:
Whats is the deal with Debug.WriteLine command...
I mean, in my programs, i usually add many of those commands to debug
it while programming, and to be able to find bugs and things easier,
but, it is safe to leave those lines when u compile the program? or
you are suposed to remove them?

Maybe the compiler delete that lines automatically when u compile the
program, but that wont make much sense since inside VS.net the
program you launch is a compiled version.... so?

I do not quite understand. The compiler does not remove the lines because
they are not executed before the programm runs, so removing it before
wouldn't make sense because it would be equal to not writing them at all.
debug.writeline will
"run" all the time and will only output something if its running
inside the VS.net IDE?
Yes

, if so, maybe there is any other way to
"retrieve" those values?

You could write a log file or display message boxes (if possible).
is it possible to read the debug.writeline
outputs running a program outside of the IDE ?

I'm not sure, but I don't think so. Have a look at the docs on the debug
class. There seems to be a longer explanation and links to other debug/trace
topics - however I haven't read the details yet.

See also:
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/cpguide/html/cpcondebuggingprofili
ng.htm

ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB/vsintro7/html/vxoriBuildingDebuggi
ngandTesting.htm

(see hints in signature)
I would like if ppl can comment here what they know about this....


--
Armin

- Links might be split into two lines. Concatenate them using notepad.
- Links might require to add a ".nnnn" after the "2003FEB", e.g.
"2003FEB.1033" for localized versions.
- Links starting with "ms-help" are URLs for the document explorer (<F1>).
Paste them in the URL textbox and press enter. Using internal help (menu
tools -> options -> environment -> help), display the "Web" toolbar that
contains the textbox.
 
Whats is the deal with Debug.WriteLine command...
I mean, in my programs, i usually add many of those commands to debug
it while programming, and to be able to find bugs and things easier,
but, it is safe to leave those lines when u compile the program? or
you are suposed to remove them?

Maybe the compiler delete that lines automatically when u compile the
program, but that wont make much sense since inside VS.net the program
you launch is a compiled version.... so? debug.writeline will "run"
all the time and will only output something if its running inside the
VS.net IDE? , if so, maybe there is any other way to "retrieve" those
values? is it possible to read the debug.writeline outputs running a
program outside of the IDE ?

I would like if ppl can comment here what they know about this....

If your program is compiled in Release mode, no code is generated for
Debug .WriteLine. See the docs. Here is a quote:

<quote>
By contrast, Debug is disabled in release builds by default, so no
executable code is generated for Debug methods.
</quote>

Look in the docs about the Trace class and Debug Class.

Chris
 
Back
Top