G
Guest
How can I tell if my C# code is running in debug mode?
I need to execute some extra code only when my project has been compiled in
debug mode. In release mode I don't want to execute this extra code.
I was looking for something simple I could test like:
#if DEBUG
do_extra_code
#endif
But, the DEBUG constant doesn't seem to be defined automatically within
Visual Studio just because you've built your project in debug mode.
In the end I had to manually add a "Conditional Compilation Constant" to:
DEBUG in the project's property pages. Then my #if DEBUG statement worked as
expected.
Is there a predefined constant that I can check instead of having to set
this up myself in the project's property pages?
Thanks.
I need to execute some extra code only when my project has been compiled in
debug mode. In release mode I don't want to execute this extra code.
I was looking for something simple I could test like:
#if DEBUG
do_extra_code
#endif
But, the DEBUG constant doesn't seem to be defined automatically within
Visual Studio just because you've built your project in debug mode.
In the end I had to manually add a "Conditional Compilation Constant" to:
DEBUG in the project's property pages. Then my #if DEBUG statement worked as
expected.
Is there a predefined constant that I can check instead of having to set
this up myself in the project's property pages?
Thanks.