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 support. Fortunately, the compiled nature of ASP+ means that debugging web applications is
no different than debugging any other managed application, and the NGWS SDK includes a lightweight visual debugger that is perfectly
suited for this task.
<p>
This section describes the steps required to debug ASP+ applications using the visual debugger provided in this SDK. The NGWS
SDK visual 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 debugger features.
<h5>Enabling Debug Mode for ASP+ Applications</h5>
Because many parts of an ASP+ application are dynamically compiled at runtime (.aspx and .asmx files, for example), you must
configure the ASP+ 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, as well as how to map breakpoints in code to lines in those
source files. To configure an application to compile with symbols, include a <b>DebugMode</b> attribute on the <b>Compilation</b> section of the config.web file at the application's root directory.
<div class="code"><pre>
<configuration>
<compilation debugmode="true"/>
</configuration>
</pre></div>
<b>Important: </b> This setting should only be enabled when you are debugging an application, as it will significantly affect the
performance of the application.
<p>
<h5>Debugging ASP+ Applications</h5>
Once DebugMode has been enabled for the application, you should issue a request to the page you wish to debug. This
will ensure that the ASP+ runtime process (xspwp.exe) is created and the application is loaded into memory.
<p>
Follow these steps to begin debugging:
<ol>
<li>Launch the NGWS SDK debugger, DbgUrt.exe.
<li>Use the File...Open menu to open the source file for the page you wish to debug.
<li>From the Debug menu, choose "Programs". The dialog in the figure below will appear.
<li>Find the "xspwp.exe" process and double-click it to bring up the "Attach to Process" dialog.
<li>Make sure your application appears in the list of running applications, and select "OK" to attach.
<li>Close the "Programs" dialog.
</ol>
<div class="indent">
<img src="/quickstart/aspplus/images/debug1.gif">
</div>
<p>
<b>Important: </b> When attached to the xspwp.exe process all threads in that process are frozen.
Under no circumstances should you debug a live production application, since client requests will not execute normally
until the debugger is detached.
<h5>Setting Breakpoints</h5>
To set a breakpoint in you page, click the left-hand margin on a line containing an executable statement or function/method signature.
A red dot will appear where the breakpoint is set. Hover over the breakpoint to ensure that it is appropriately mapped to
the correct application instance in the xspwp.exe process.
<p>
Re-issue the request to the page from your browser. The visual debugger will stop at the breakpoint and gain the current window focus.
From here you can step, set variable watches, view locals, stack info, disassembly, etc. 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.
<p>
<div class="indent">
<img src="/quickstart/aspplus/images/debug2.gif">
</div>
<h5>Generating Symbols for Pre-compiled Components</h5>
To 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 via a path-based search algorithm. The algorithm
used by the PDB Library (mspdb69.dll) to find symbolic information is outlined below.
<ol>
<li>Search same path as assembly (this is the normal location for pdb files).
<br>For local assemblies, place the symbols (.pdb files) in the application's /bin directory along with the dlls.
<li>Search path as specified in the PE file (the NB10 debug header).
<li>Search NT symbol file locations (environment variables NT_SYMBOL_PATH and NT_ALT_SYMBOL_PATH).
</ol>
<b>Note: </b> If symbolic information cannot be found, the debugger will prompt for a user-specified location.
<h4>Section Summary</h4>
<ol>
<li>The NGWS SDK visual debugger supports manual-attach debugging of processes on a local development computer.
<li>DebugMode allows the ASP+ runtime to dynamically compile with symbolic information. Enable this by setting
<nobr><compilation debugmode="true"/></nobr> in the application root's config.web file. The DebugMode setting should only be
enabled when you are debugging an application, as it will degrade application performance.
<li>To debug an application, issue a request to a page, attach the debugger to the xspwp.exe process, set breakpoints and re-issue the page request.
<li>When attached to the xspwp.exe process all threads in that process are frozen.
Under no circumstances should you debug a live production application, since client requests will not execute normally
until the debugger is detached.
<li>To debug pre-compiled components such as business objects or code-behind files, you must compile with symbolic