Reputation: 50728
For some reason, Any code like:
#if DEBUG
CallSomeMethod();
#endif
Is always true regardless of debug or release mode. Any ideas why, and what setting I can use to turn the feature on or off? For the project, define DEBUG constant is set to true.
Thanks.
Upvotes: 10
Views: 6250
Reputation: 11
I had kept the "Define DEBUG Constant" unchecked in Release configuration. Still, when I ran the Application after publishing it, it was running in Debug mode.
Because I when I published the application, 'Debug' Option was selected in configuration. A silly mistake.
Make sure 'Release' is selected in this configuration when you publish: Select 'Release' option in Configuration
Upvotes: 1
Reputation: 2368
None of the above worked for me. In my case, someone had set the configurations of all projects to point to debug. I reverted the changes and it worked. So if the above solutions do not work for you, check your Configuration Manager and verify that the Configuration is set correctly.
Upvotes: 1
Reputation: 16162
When #if DEBUG
, the code will be omitted out to gray scale when you are in release mode, you can see that your self using the visual studio IDE. if that is not the case them maybe like @Kragen suggested that you define DEBUG
somewhere in your class so it affect the release too.
Upvotes: -1
Reputation: 5164
You should be able to select the release mode in your project properties. Right click your project, select Properties and click the build tab on the left of the window. From there, you can uncheck the "define DEBUG constant" box. Make sure you do this for the release build, and not the debug mode.
Upvotes: 19
Reputation: 86789
This will be because the DEBUG
constant is also true for the release mode.
There is nothing special about the build mode - its just a collection of build settings with a name. If you wanted you could create a "Release" mode with all of the normal "Debug" mode settings (and visa versa).
Upvotes: 0
Reputation: 60276
Seems like you're answering your own question:
For the project, define DEBUG constant is set to true.
This should only be set conditionally in the build file, and not always.
Upvotes: 5