Compilation behavior of ASP. NET 2.0

Source: Internet
Author: User

During the migration from ASP. net1.1 to 2.0, we made adjustments in how to generate the debug and release build (builds.

1.1

In 1.1 (the corresponding IDE is vs2003), there is a Configuration Manager menu item under the build menu. click this menu item to bring up a dialog box from which you can select some available build configurations. by default, vs2003 provides the debug and release configurations. the configuration information selected in the Configuration Manager tells Visual Studio how to compileCode-behindFile. after successful compilation, a file is generated in the bin directory. DLL file (note: the PDB file is not generated when the release mode is selected). If you need to generate a debug symbol (debugging symbols) during configuration, A file with the suffix PDB is generated in the bin directory at the same time (Note: Select debug mode to generate the PDB file ).

Later, when this applicationProgramWhen a Web request is received, the ASP. NET Runtime (runtime) isWebForms and user control)GenerateCodeAnd compile the generated code (the code here should refer to the msil code ). during the runtime, the JIT compilation will be based on the Web. debug setting in the compilation section of config to determine whether to compile the Optimized Code and whether to generate debugging information. ASP. net will put the generated results to the temporary ASP.. Net file directory (temporary ASP. net file ). in vs2003, only the release mode andAt the same timeYou can set debug to false in Web. config to generate a product without debugging symbols.

2.0

There is a very important concept in 2.0: vs2005 does not know any information about compiling a web application (knows nothing ).In 1.1, Visual Studio constructs the code-behind file, and Asp.net is responsible for building Web forms.In 2.0AllAll compilation work is handed over to the ASP. NET platform.

With these concepts, there are two scenarios to be explored: Building a web application without a Web site deployment project and building a web application with a web site deployment project. let's first look at the first one. When you let Visual Studio build a web project, it seems that nothing has happened. you have not created a bin directory in your project, which contains the compiled DLL. this is because it is ASP.. net instead of Visual Studio. ASP. net to build everything, including. CS and. VB file. ASP. net put the result assembly to temporary ASP.. Net Files directory, you can open it by yourself. because it is ASP. netAllSo web. the debug settings in the complilation section in config control the current debug mode or release mode. when debug is set to true, you will find that when the Assembly is generated, a PDB file will be generated to save debugging information. this new compilation mode makes the Configuration Manager obsolete for a web site project. only one debug option can be seen in the Configuration Manager of vs2005. don't worry. There is no problem. actually web. the debug settings in config control this (it has nothing to do with the Configuration Manager ). when you plan to deploy the application, you can release the website, build the entire web application, and save the results in the directory you choose. you can also publish it to IIS or FTP. when you choose to publish the publish command, you will see a dialog box where you can select the target location, strong naming options, and so on. these options correspond to some of the switches used in the command line tool aspnet_compiler. the aspnet_compiler tool also provides a switch for generating debugging symbols, but this option is unavailable in the publish dialog box. release always pre-compiles a release version that does not contain debugging information.

Note: The publish command does not change the web. debug settings in config. the release command always compiles a release version. then, if you want to pre-compile an updateable site, you can update the site as appropriate (this will cause dynamic compilation ), such dynamic compilation will generate debug code and PDB files.

The new web site deployment project slightly changed the scenario mentioned above. WSD adds the release and debug configurations in the Configuration Manager of Visual Studio 2005. however, this does not mean that Visual Studio knows how to compile the web site. instead, Visual Studio knows how to use the msbuild file provided by WSD to build a debug or release version. now you can select debug or release in the Configuration Manager. such a request is finally sent to aspnet_complier for execution, and the same is true for issuing commands.

Unlike the release command, a WSD release build changes the web. set debug in config to false. in addition, WSD will put the release build into the release directory by default, and put the debug build into the DEBUG directory, which is used. NET developers are familiar with developing non-web form programs.

After Visual Studio 2005 Service Pack 1 is installed, you can create a web application. In vs2005, the compilation behavior of the Web application is different from that of the web site. for a web application project, both Debug and release modes are available in the Configuration Manager. However, no matter which mode is selected, the generated program contains a PDB file, even if you are on the web. in the compilation section of config, setting debug to false does not work. select publish to publish a web application with a PDB file containing the debugging symbol. is there no way to release an assembly without the PDB file? Of course there will be a way. In the web application project file attributesÀGenerateÀAdvanced, you can see the following dialog box:


When none is selected, an assembly without the PDB file is generated.

 

conclusion: You can use the web. the configuration of the debug section in config controls whether to generate the debug version or the release version ( the previous sentence is not applicable to Web applications ). except when you use the publish command to pre-compile the web site or use the web site deployment tool. WSD allows you to select whether to generate the debug or release version, pre-compile the web site, and modify the web. config debug settings.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.