问题
I seem to be having trouble with preprocessor directives in C#. I've created a Visual Studio 2008 C# win forms app. I add this:
#if (DEBUG)
textBox1.Text = "in debug mode";
#else
textBox1.Text = "in release mode";
#endif
And when I run in debug I see the expected "in debug mode". However when I switch to Release, compile, and run the .exe, I still see the "in debug mode" text. In my project properties I have Define DEBUG
constant checked. I even get the correct color-coded syntax for the code above. What gives?
回答1:
Any chance you have DEBUG defined for both Debug and Release configurations?
回答2:
Do you have a "#define DEBUG" line ? That sets DEBUG to true always.
来源:https://stackoverflow.com/questions/637061/pre-processor-directives-in-c-sharp