sdk debugger

Upload: justin-cook

Post on 30-May-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 SDK Debugger

    1/3

    The Microsoft .NET Framework SDK Debugger

    No 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 thatdebugging Web applications is no different than debugging any other managed

    applications, and the .NET Framework SDK includes a lightweight debugger thatis perfectly suited for this task.

    This section describes the steps required to debug ASP.NET Frameworkapplications using the debugger provided in this SDK. The debugger supports

    manual-attach debugging of processes on a local development computer. Thedebugger documentation included in this SDK is your best resource for

    information about specific features.

    Enabling Debug Mode for ASP.NET Applications

    Because many parts of an ASP.NET Framework application are dynamically

    compiled at runtime (.aspx and .asmx files, for example), you must configurethe 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 tolines in those source files. To configure an application to compile with symbols,

    include a debug attribute on the compilation section within the system.webgroup of the Web.config file at the application's root directory, as follows:

    Important: You should only enable this setting when you are debugging an

    application, because it can significantly affect application performance.

    Debugging ASP.NET Applications

    When you have enabled debugging for the application, you should issue arequest 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:

    1. Launch the .NET Framework debugger, DbgClr.exe.

    2. Use the File...Miscellaneous Files...Open File menu to open the

    source file for the page you want to debug.3. From the Tools menu, choose Debug Processes. The screen in the

    figure following these instructions will appear.

    4. Check the Show system processes checkbox, if it is not checked.

    5. Find the Aspnet_wp.exe process and double-click it to bring up the

    Attach to Process dialog.

    6. Make sure your application appears in the list of running

    applications, and select OK to attach.

    7. Close the Programs dialog.

  • 8/14/2019 SDK Debugger

    2/3

    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 liveproduction application, because client requests can not execute normally until

    the debugger is detached.

    Setting Breakpoints

    To set a breakpoint in your page, click the left-hand margin on a line containingan 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 isappropriately 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 atthe breakpoint and gain the current window focus. From this point, you canstep, set variable watches, view locals, stack information, disassembly, and so

    on. You can see the intrinsic objects on the page, like Request, Response, andSession by using this (C#) or Me (VB) in the watch window.

    Section Summary

    1. The debugger described in this section supports manual-attachdebugging of processes on a local development computer.

    2. Debugging allows the ASP.NET runtime to dynamically compile with

    symbolic information. Enable this by setting in the Web.config file located in the application's rootdirectory. The debugger setting should only be enabled when you aredebugging an application, because it degrades application performance.

    3. To debug an application, issue a request to a page, attach thedebugger to the Aspnet_wp.exe process, set breakpoints, and reissue the

    page request.4. When attached to the Aspnet_wp.exe process, all threads in that

    process are frozen. Under no circumstances should you debug a live

  • 8/14/2019 SDK Debugger

    3/3

    production application, since client requests can not execute normallyuntil the debugger is detached.

    5. To debug pre-compiled components, such as business objects orcode-behind files, you must compile with symbolic information prior to

    debugging.