Debug class in Release mode

V

vicky

i am using some debug class function like Debug.Writeline()
i just want to know when i am compiling this code in Release mode,,,as
does complier ignore this line or compile it.

all debug class functions are ignored by compiler in release mode?????
or
these functions are also compiled by compiler but not seen in release
mode!!!!

vishal
 
V

vicky

sorry adding some more doubts....
what i got that compiler doesn't ignore debug functions in release mode
but it doesn't put these functions in IL as i checked with ildasm....no
debug.writeline call is there

what acually debug.writeline is haveing particularly so that it is not
added in IL in release mode??
 
B

Brian Gideon

Hi,

Debug.WriteLine has the Conditional("DEBUG") attached to it. The
compiler recognizes that and only includes it in the build if DEBUG is
defined. You can define your own methods this way as well.

Can you see the advantage of using the Conditional attribute over
#if...#else...#endif? The compiler can exclude methods from assemblies
that have already been compiled which you use in your assembly by
recognizing the existence of that attribute.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top