Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


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

↑ Back to the top


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

↑ Back to the top


More Information

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

Configuring the Application

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:
<configuration>
<compile debug=true/>
</configuration>
Alternatively, you can set the Debug attribute of the Page directive to true in your .aspx pages, as follows:
<%@ Page Debug="true" %>
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

  1. 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
  2. Use a Web browser to browse to the application that you want to debug to ensure that the Aspnet_wp.exe process is started.
  3. Open the source file that you want to debug: on the
    File menu in the CLR Debugger, click
    Open.
  4. On the Tools menu, click Debug Processes.
  5. In the Processes dialog box, select
    Show system processes.
  6. Double-click Aspnet_wp.exe and verify that it appears in the Debugged Processes list. Close the Processes dialog box.
  7. Set a breakpoint in the source file:
    • Either select the line on which you want to set the breakpoint, and then press F9.
      - or -
    • Click in the margin by the line on which you want to set the breakpoint.
  8. 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.
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

Notes

When the debug attribute in the Web.config file is set to true, it generates symbolic information every time the compiler compiles your .aspx pages as well as disables code optimization. If the application is not being debugged, you should change this attribute to false.

While the debugger is attached and in break mode, no requests to pages in the application execute. Therefore, you should not debug an application on a production Web server while it is in use.

Only one debugger can be attached to the Aspnet_wp.exe process at a time.

The CLR Debugger only debugs managed code, and it only debugs applications on the computer on which the CLR Debugger is running. If you need to debug remotely or if you need to debug code other than managed code, you should use the Visual Studio .NET debugger.

back to the top

↑ Back to the top


References

For more information on the Microsoft DbgCLR debugger, visit the following Microsoft Web site:
Debugging with the Microsoft .NET Framework SDK
http://msdn2.microsoft.com/en-us/library/aa309372(VS.71).aspx
 For additional information about how to perform this task by using Microsoft Active Server Pages, 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
back to the top

↑ Back to the top


Keywords: kbaspwpswept, kbdebug, kbdsupport, kbhowtomaster, kb

↑ Back to the top

Article Info
Article ID : 301058
Revision : 3
Created on : 4/18/2018
Published on : 4/19/2018
Exists online : False
Views : 142