The Microsoft .NET Framework SDK DebuggerNo matter how skilled a programmer you are, you are bound to make mistakes once in a while. Tracking down problems in your code can be baffling without the appropriate tool. Fortunately, the compiled nature of ASP.NET means that debugging Web applications is no different than debugging any other managed applications, and the .NET Framework SDK includes a lightweight debugger that is perfectly suited for this task.This section describes the steps required to debug ASP.NET Framework applications using the debugger provided in this SDK. The debugger supports manual-attach debugging of processes on a local development computer. The debugger documentation included in this SDK is your best resource for information about specific features. Enabling Debug Mode for ASP.NET ApplicationsBecause many parts of an ASP.NET Framework application are dynamically compiled at runtime (.aspx and .asmx files, for example), you must configure the ASP.NET runtime to compile the application with symbolic information before the application can be debugged. Symbols (.pdb files) tell the debugger how to find the original source files for a binary, and how to map breakpoints in code to lines in those source files. To configure an application to compile with symbols, include a debug attribute on the compilation section within the system.web group of the Web.config file at the application's root directory, as follows:<configuration> <compilation debug="true"/> </configuration>
Debugging ASP.NET ApplicationsWhen you have enabled debugging for the application, you should issue a request to the page you want to debug. This ensures that the ASP.NET runtime process (Aspnet_wp.exe) is created and the application is loaded into memory.To begin debugging:
Important: When you attach to the Aspnet_wp.exe process, all threads in that process are frozen. Under no circumstances should you attempt to debug a live production application, because client requests can not execute normally until the debugger is detached. Setting BreakpointsTo set a breakpoint in your page, click the left-hand margin on a line containing an executable statement or function/method signature. A red dot appears where the breakpoint is set. Move the mouse over the breakpoint to ensure that it is appropriately mapped to the correct application instance in the Aspnet_wp.exe process.Reissue the request to the page from your browser. The debugger will stop at the breakpoint and gain the current window focus. From this point, you can step, set variable watches, view locals, stack information, disassembly, and so on. You can see the intrinsic objects on the page, like Request, Response, and Session by using this (C#) or Me (VB) in the watch window.
Generating Symbols for Pre-Compiled ComponentsTo debug pre-compiled components, such as business objects or code-behind files, you must compile with symbolic information prior to debugging. Symbols for assemblies are typically found by means of a path-based search algorithm. The algorithm used by the PDB library (Mspdb70.dll) to find symbolic information is as follows:
Section Summary
|