Labels

Showing posts with label .Net Framework. Show all posts
Showing posts with label .Net Framework. Show all posts

Monday, September 24, 2007

DLL/PDB file generation in ASP.Net

http://odetocode.com/Blogs/scott/archive/2005/11/15/2464.aspx

Debug and release builds are based on two things

§ .Net 1.x / .Net 2.0

§ Project Type [ Class Library / Web Site/ Web Service]

1.x

§ In 1.x, you can decide whether you need the build in ‘Debug’ or ‘Release’ mode by using the Build -> Configuration Manager menu option.

§ This works for all three type of projects viz. Class Library, Web Project and Web Service.

§ Class Library

o Debug Mode – bin\Debug\ClassLibrary1.dll and bin\Debug\ClassLibrary1.pdb

o Release Mode - bin\ Release \ClassLibrary1.dll [No .pdb is generated]

o

§ Web Project /Web Service

o Debug Mode – bin\Debug\ WebApplication1.dll and bin\Debug\ WebApplication1.dll.pdb

o Release Mode - bin\Debug\ WebApplication1.dll

M. Imp - Though the build in ‘Release’ mode can be decided thru Build -> Configuration Manager, however it is important to set debug=”false” along with ‘Release’ configuration in web.config to produce a true production ‘Release’ build in 1.x.

2.0

§ .Net 2.0 behaves almost different to the .Net 1.x approach.

§ For class library projects whether you need the build in ‘Debug’ or ‘Release’ mode is decided by using the Build -> Configuration Manager menu option. However .pdb files still gets created in the ‘Release’ mode as well.

§ But for Web Site/Web Services – Something different happens as below.

§ The most important concept to come to terms with in 2.0: Visual Studio 2005 knows nothing about compiling a web application and it delegates all compilation responsibilities to the ASP.NET platform.

§ When you ask Visual Studio to build a web project, nothing seems to happen. We don’t get the comforting feeling of having a bin directory with a .dll file inside. This is because ASP.NET performs the build and not Visual Studio.

§ ASP.NET builds everything, including .cs and .vb code files. Instead of creating ‘bin’ directlory with a .dll file inside, ASP.NET places all the resulting assemblies in a folder underneath the Temporary ASP.NET files directory [C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files].

§ Because ASP.NET does all of the compilation, the debug setting in the compilation section of web.config controls debug or release mode. Compile with debug=”true” and you’ll find the .pdb debugging symbol files alongside each assembly.

§ This new compilation model makes the Configuration Manager for a web site obsolete. The only option appearing in a Visual Studio 2005 web site “project” is a Debug configuration. Don’t fret – it means nothing. The web.config file now rules the school.

Class Library

o Debug Mode – bin\Debug\ClassLibrary1.dll and bin\Debug\ClassLibrary1.pdb

o Release Mode - bin\ Release \ClassLibrary1.dll and bin\ Release \ClassLibrary1.pdb [Yes .pdb is also generated in ‘Release’ Mode as well.]

§ Web Project /Web Service

o Debug Mode – Check Temporary ASP.NET files directory

o Release Mode – Check Temporary ASP.NET files directory

Summary

.Net 1.x –

§ For all types of projects - Build in ‘Debug/Release’ mode can be decided thru Build -> Configuration Manager.

.Net 2.0 –

§ For Class Library Projects - Build in ‘Debug/Release’ mode can be decided thru Build -> Configuration Manager

§ For WebSite/Web Services - Build in ‘Debug/Release’ mode can be decided thru Web.config.

Publish Web Site-

§ Publish will always precompile a Release build without debugging symbols.

§ The Publish command [Build -> Publish] does not change the debug setting in web.config. The Publish command always compiles for “Release”.

§ However, if you precompile to an updateable web site, and then update the web site in place (which results in dynamic compilations), those dynamic compilations will produce debug code and pdb files.

Thanks & Regards,

Arun Manglick || Tech Lead

Debug vs Release Mode

PDB Files.

Note:

§ To build ‘Class Library’ type of projects in ‘Release’ mode, you require is to set it to ‘Release’ mode either using toolbar or menu [Build -> Configuration Manager dialog]

§ To build ‘Web Service/Website’ type of projects in ‘Release’ mode, set the ‘debug=false’ attribute in ‘compilation’ tag of Web.config.

§ PDB files are used to store debugging and project state information and they are created when you compile the application.

§ They are required for debugging.

§ A PDB file is created when you compile a Visual Basic/C#/JScript .NET program with /debug.

o The /DEBUG option creates debugging information for the .exe file or DLL.

o The linker puts the debugging information into a program database (PDB). It updates the PDB during subsequent builds of the program.

o An .exe file or DLL created for debugging contains the name and path of the corresponding PDB.

o The debugger reads the embedded name and uses the PDB when you debug the program.

o The linker uses the base name of the program and the extension .pdb to name the program database, and embeds the path where it was created.

§ The major Difference Between Debug And Release is that Optimization Is Turned On And Debug Symbols Are Not Emitted. Most of this optimization is done by the JITR and not the language compiler.

§ Having the solution in Debug mode makes the app run slower, use more memory, etc. It is only necessary for debugging/tweaking. You should only change it to release when you want to use the files in production/live.

§ Release compilations execute faster than Debug.

o The Debug configuration of your program is compiled with Full Symbolic Debug Information in Microsoft format and no optimization (optimization complicates debugging, since the relationship between source code and generated instructions is more complex).

o The Release configuration of your program is fully optimized and contains no symbolic debug information. Debug information may be generated in separate PDB files.

§ Performance is generally better if you compile in release mode, but you will notice a drastic change when errors DO occur because the debug symbols are not created. Therefore, debugging can become significantly more difficult.

§ M. Imp - In Release mode, we cannot attach debugger to the aspnet_wp process. i.e Breakpoints will not work and will behave as below figure.













Thanks & Regards,

Arun Manglick || Tech Lead |