
3.18.2002
Debugging
Tons of good info on debugging in PDC2001 talk.
Some tidbits:
- Processes dialog - ability to debug more than one process at a time...and detach from process (allowing it to continue to run) at the end of debug session
- Customize F5 - tell the debugger what to launch (remote process, URL, etc) when hit F5
- JIT debugging - add <system.winforms.forms jitDebugging="true"/> in configuration section
Debugging ASP.NET
Although you can mostly do this automatically with F5, which attaches to the aspnet_wp.exe process and kicks off a new request...you can also manually attach to the aspnet_wp.exe process...do the debugging...then detach from process!
Remote Debugging ASP.NET
Must have debug components setup on web server machine. Usually this doesn't mean installing vs.net -- rather run the install and choose "remote component setup". You must be admin to debug, and the installation adds the user doing the install to the debugger group.
Trace & Debug
Both have same methods - Debug is for development, and Trace is for deployment.
- Calls on Debug class will be skipped by compiler in release builds - since the DEBUG symbol is not defined (project properties, build, code generation).
- Calls on Trace class will be included (by default, TRACE is defined for release build), but can be turned on/off with config files.
Trace output by default goes to DefaultTraceListener (OutputDebugString). Also have EventLogTraceListener and TextWriterTraceListener. Use Trace.WriteLineIf( someSwitch.Enabled, "i am here" ); Setup config file entry like so:
<configuration>
<system.diagnostics>
<switches>
<add name="mySwitch" value="10" />
<add name="myNewSwitch" value="20" />
</switches>
</system.diagnostics>
</configuration>
With the above settings and code, trace output will go to OutputDebugString target (usually the currently attached debugger).
Users out in the field can't usually capture OutputDebugString, so configure a "listener" in the config file.
<system.diagnostics>
<trace autoflush="true" indentsize="4">
<listeners>
<add name="lis" type="Sytsem.Diagnostics.TextWriterTraceListener"
initializeData="c:\trace.log"/>
</listeners>
</trace>
</system.diagnostics>
Tracing ASP.NET
This is completely different that tracing a .NET process as described above. We really need to trace a given request through the aspnet_wp.exe process. Do this with Trace class - which is different than the Trace class used above. Trace is a property of type TraceContext in the System.Web.UI.Page class. Warn and Write methods are identical, except Warn output comes out bold red in the trace output.
Enable application level tracing (all pages in the directory/application) with:
<trace enabled="true" pageOuput="false"/>
Then browse to trace.axd in web application root directory to view trace results. Set pageOutput="false" to view the trace output on the page itself. You can also enable page level tracing with <%@ Page trace="true" >
Hidden Goodies
Expand your types automatically in the debugger watch windows (IDE reads these files only at startup):
- mcee_cs.dat --- c#
- mcee_mc.dat --- managed c++
( found in MS VS.NET\common7\packages\debugger )
Comments:
Post a Comment