Microsoft KB Archive/301058

= How To Debug an ASP.NET Application with the Microsoft CLR Debugger =

Article ID: 301058

Article Last Modified on 4/12/2007

-

APPLIES TO


 * Microsoft ASP.NET 1.0
 * Microsoft .NET Framework Software Development Kit 1.0
 * Microsoft .NET Framework Service Pack 2
 * Microsoft ASP.NET 1.1
 * Microsoft .NET Framework Software Development Kit 1.0 Service Pack 2
 * Microsoft Common Language Runtime (included with the .NET Framework 1.1)

-



This article was previously published under Q301058



For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

299986 How To Use an ASP Debug Object to Debug ASP Pages

IN THIS TASK

 * SUMMARY
 * Requirements
 * Configuring the Application
 * Enable Debugging in Web.config
 * Generate Symbolic Information for Precompiled Components
 * Debugging the Application
 * Notes
 * REFERENCES



SUMMARY
The Microsoft .NET Framework Software Development Kit (SDK) contains a lightweight debugger for debugging .NET applications on computers that do not have Visual Studio .NET installed.

This article describes how to configure your ASP.NET application for debugging, how to attach to the ASP.NET worker process (Aspnet_wp.exe) with the Microsoft CLR Debugger, and how to debug the application.

back to the top



Requirements
The following list outlines the recommended hardware, software, network infrastructure, skills and knowledge, and service packs that are required:
 * Microsoft Windows 2000 or Microsoft Windows XP
 * Microsoft .NET Framework
 * Microsoft .NET Framework Software Development Kit (SDK)
 * Microsoft Internet Information Server (IIS) 5.0 or later

back to the top

Enable Debugging in Web.config
Because many parts of an ASP.NET application (such as .aspx, .asmx and .ascx pages) are dynamically compiled at run-time, you need to configure the ASP.NET run-time process to compile the application with symbolic information before the application can be debugged. To do this, set the debug attribute in the configuration section of the Web.config file that is located in the root of the application folder to true, as follows: Alternatively, you can set the Debug attribute of the Page directive to true in your .aspx pages, as follows: <%@ Page Debug=&quot;true&quot; %> back to the top

Generate Symbolic Information for Precompiled Components
To debug precompiled components such as business objects and code-behind modules, you need to generate debug symbols. To do this, compile the components with the debug flags by using either Visual Studio .NET or a command line compiler such as Csc.exe (for Microsoft Visual C# .NET) or Vbc.exe (for Microsoft Visual Visual Basic .NET).

Using Visual Studio .NET
 * 1) Open the ASP.NET Web Application project in Visual Studio .NET.
 * 2) Right-click the project in the Solution Explorer and click Properties.
 * 3) In the Properties dialog box, click the Configuration Properties folder.
 * 4) In the left pane, select Build.
 * 5) Set Generate Debugging Information to 'true'.
 * 6) Close the Properties dialog box.
 * 7) Right-click the project and click Build to compile the project and generate symbols (.pdb files).

Using Command Line Compilers

Use Csc.exe for Visual C# .NET or Vbc.exe for Visual Basic .NET to compile your application with the debug:full switch to generate complete symbolic information, as follows: csc /debug:full /out:assemblyname.dll  file1.cs file2.cs ... fileN.cs vbc /debug:full  /out:assemblyname.dll   file1.vb file2.vb ... fileN.vb back to the top

Debugging the Application
 Start Dbgclr.exe from the folder in which you installed the Microsoft .NET Framework SDK. By default, and depending on whether you installed the .NET Framework SDK separately or as part of a Visual Studio .NET installation, this folder is in the following location:

C:\Program Files\Microsoft.Net\FrameworkSDK\GuiDebug

- or -

C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\GuiDebug

When you install Microsoft.Net Framework 1.1, Dbgclr.exe is located in the following folder:

C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\GuiDebug

 Use a Web browser to browse to the application that you want to debug to ensure that the Aspnet_wp.exe process is started. Open the source file that you want to debug: on the File menu in the CLR Debugger, click Open. On the Tools menu, click Debug Processes. In the Processes dialog box, select Show system processes. Double-click Aspnet_wp.exe and verify that it appears in the Debugged Processes list. Close the Processes dialog box.</li> Set a breakpoint in the source file: <ul> Either select the line on which you want to set the breakpoint, and then press F9.

- or -</li> Click in the margin by the line on which you want to set the breakpoint.</li></ul> </li> Browse to the page that you are debugging, or, if the page is already open in the browser, click Refresh. The debugger regains focus and stops on the breakpoint. From this point you can step through the code, set watches, and see local variables.</li></ol>

To see the ASP.NET intrinsic objects, add the this pointer to the watch window for Visual C# .NET or Me for Visual Basic .NET.

back to the top