Enabling Debug


Now that you’ve learned more about how the compilation system works, let’s examine the debug options that affect compilation. The Page directive supports a debug attribute, which is false by default. When this attribute is set to true, ASP.NET changes the way the file is compiled to provide us with a better debugging experience. The config files also provide a setting that causes all pages in the application to be compiled as though the debug directive were set to true. Code Listing 10-5 is an example of enabling debugging for all pages in an application.

Code Listing 10-5: Debug Web.config

start example
 <configuration>
<system.web>
<compilation debug="true" />
</system.web>
</configuration>
end example

When debug is enabled for an application, ASP.NET will compile each page separately and generate extra files in the Temporary ASP.NET files directory for the application. A .pdb file is created with symbol information as well as an .err file containing any compilation error output. The flags passed to the compiler are saved in the .cmdline file, and the output from the compiler interactions are saved in the .out file. Interestingly, the source file generated by ASP.NET from the .aspx file is preserved.

Tip

To quickly get to the source code for a page, you do not need to access the Temporary ASP.NET Files directories. Instead, introduce a deliberate syntax error. ASP.NET will flag the error and provide the Show Complete Compilation Source option as well as the compiler output.

Several of the options passed to the compiler are affected by enabling debugging. Usually, the command-line options include /debug- to disable debug information and /optimize+ to turn on compiler optimizations. When ASP.NET debug is enabled, these settings are reversed to /debug+ and /optimize- to emit debug information and disable potentially confusing optimizations. Also, /D:DEBUG is added so that conditionally included debug code will be incorporated.




Microsoft ASP. NET Coding Strategies with the Microsoft ASP. NET Team
Microsoft ASP.NET Coding Strategies with the Microsoft ASP.NET Team (Pro-Developer)
ISBN: 073561900X
EAN: 2147483647
Year: 2005
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net