Nate Pet
Nate Pet

Reputation: 46222

c# Production code running DEBUG version

I have the following code:

     #if (DEBUG)

      imgPath = GetDirectoryName(Application.ExecutablePath);

    #else

      imgPath = GetDirectoryName(Application.ExecutablePath) + "\\images\\";

    #endif

When the code went into Production (live site) , it still looked the the DEBUG version. How is this possible? Is there something during the promotion process that can indicate do RELEASE vs DEBUG

Upvotes: 1

Views: 161

Answers (2)

UnholyRanger
UnholyRanger

Reputation: 1971

When using #if statements, it is checking to determine if the constant is defined. Under the project's properties->Build section, the DEBUG constant is (by default) set to be defined when in debug mode. There is no RELEASE constant unless you define it yourself. You may have used your build from debug mode or had the "Define DEBUG constant" checked for your release build. Double check which you used and your build settings.

Also, your code should be greyed out to indicate that VS will not be compiling that code. So if the code you wish to be using is grey, that is an indicator you have DEBUG defined somewhere.

Upvotes: 1

dutzu
dutzu

Reputation: 3910

You might have deployed a version with binaries taken from a Debug build configuration or in any case, the DEBUG variable set to True.

You need to build in RELEASE and use that output as the release candidate.

Upvotes: 1

Related Questions