DEBUG is defined when publishing

I have a strange problem

#if (!DEBUG)
    checkLicense();
#endif

This works correctly in Releaseand configurations Debug. But when I try to publish using the release configuration, this condition is not met. It looks like the publication is using debug dll.

What did I miss?

+5
source share
3 answers

There is a parameter to control whether the DEBUG constant is defined for each project based on different deployment modes. See. This response , to ensure that the constant is defined for the "release mode", making sure that the check box Define DEBUG constant is marked .

, , , ELSE, .

, , , , machine.config :

<deployment retail="true" />

web.config false .NET .

, , . , , , .

+3

, , "" try\catch.

#if (!DEBUG)
MessageBox.Show("I'm in");
try{
    checkLicense();}
catch{MessageBox.Show("ERROR IN checkLicense");}
#endif

. "if", , , .

#if DEBUG
....
#else
.....
0

An alternative to my other answer, because I just noticed the mvc tag, whereas earlier I assumed that you were using WebForms.

Is the piece of code you provided in the view?

Because if this is the case, the DEBUG parameter for your project will not be respected when the view is created at runtime - it will only respect the debug flag in your web.config file.

See this answer for more information.

0
source

All Articles