Вопрос

If you build and publish an ASP.NET web application in Release mode, does the debug="true" in the following web.config line in the development environment make any difference?

<compilation defaultLanguage="vb" debug="true" />

Obviously you would always have debug="false" on the production server - that is not in question.

My question is whether I should be setting debug="false" when I build the DLL's for publishing to the production system.

At the moment I don't, as it's a PITA to have to remember to change it between true for development and false for release. I'm hoping the answer is "it makes no difference".

(I'm using Visual Studio 2010 with .NET 4.0 - the solution contains both VB.NET and C# projects, due to legacy reasons).

Это было полезно?

Решение

Please read the following article about the importance of running debug="false"

Excerpt:

[Keeping the debug="true"] causes a number of non-optimal things to happen including:

1) The compilation of ASP.NET pages takes longer (since some batch optimizations are disabled)

2) Code can execute slower (since some additional debug paths are enabled)

3) Much more memory is used within the application at runtime

4) Scripts and images downloaded from the WebResources.axd handler are not cached


After freefaller's remark i'd like to add that the configuration value is not important at the time of publishing, only at the time of running. So you could compile your assembly in release mode with debug="true" and deploy it with debug="false" without any problem. The parameter only acts on runtime configuration

Другие советы

There is a big difference between the compilation model of the assemblies and the debug mode of the ASP.NET application.

The assemblies in release mode allow the compiler to make optimizations to make the code faster and in general to consume less resources.

In opposite, the <compilation debug="true" /> makes the application slow and consume more memory, in general all the disadvantages reported in the answer above.

I think the VS will not take the value of debug attribute of the compilation tag in web.config when programmer rebuild the project.
I left the value of debug attribute as "debug" when I rebuild my project with the Configuratoin=release. And then I download the the utility .NET Assembly Information to check the output of my build. I find that those dlls are all "release" !!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top