0

Have tried adding this to web.config

<compilation debug="false" targetFramework="4.0">
</compilation>

but website still executes code in #if DEBUG when it shouldn't

*Wierdly the inline statement <% #if DEBUG %> on aspx files works but require also for .cs code.

NB development and live website on same box

1
  • Is this a Web Site or Web Application project? Commented Jan 29, 2014 at 17:51

3 Answers 3

1

#if directives in backend .cs files are handled by the C# compiler, not ASP.Net.
Set your project to the Release configuration so that that symbol is not defined when compiling the DLL in VS.

Sign up to request clarification or add additional context in comments.

Comments

0

compilation debug element is not the same thing as DEBUG preprocessor directive. You need to re-compile your website in Release mode.

What about binaries compiled with debug symbols?

One scenario that several people find very useful is to compile/pre-compile an application or associated class libraries with debug symbols so that more detailed stack trace and line error messages can be retrieved from it when errors occur.

The good news is that you can do this without having the have the switch enabled in production. Specifically, you can use either a web deployment project or a web application project to pre-compile the code for your site with debug symbols, and then change the switch to false right before you deploy the application on the server.

The debug symbols and metadata in the compiled assemblies will increase the memory footprint of the application, but this can sometimes be an ok trade-off for more detailed error messages.

http://weblogs.asp.net/scottgu/archive/2006/04/11/Don_1920_t-run-production-ASP.NET-Applications-with-debug_3D001D20_true_1D20_-enabled.aspx

Comments

0

Ensure the compile configuration to release as well. In Visual Studio, Build Menu > Configuration Manager and make sure "Release" is selected for all your assemblies, and/or is the active solution configuration.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.