Fri
Jan 19
2007

CLR Debugging

To get started with debugging the CLR see Tess Ferrandez’s post on getting .NET memory dumps and Associating Windbg with .dmp files. See her other posts for mining these dumps for useful information.

To debug ASP.Net worker process crashes, create a batch file named debug_crash_iis5.bat in windbg folder with:
cscript.exe adplus.vbs -crash -pn aspnet_wp.exe -FullOnFirst

To dump (non-crashing) exceptions from ASP.Net, create a batch file named debug_monitor_iis5.bat with:
cscript.exe adplus.vbs -pn aspnet_wp.exe -c TrackCLR.cfg

and another file named TrackCLR.cfg with:

<ADPLUS>
  <SETTINGS>
   <RUNMODE>CRASH</RUNMODE>
  </SETTINGS>
  <PRECOMMANDS>
   <CMD>!load clr10\sos</CMD>
  </PRECOMMANDS>
  <EXCEPTIONS>
   <OPTION>NoDumpOnFirstChance</OPTION>
   <OPTION>NoDumpOnSecondChance</OPTION>
   <CONFIG><!-- This is for the CLR exception -->
    <CODE>clr</CODE>
    <ACTIONS1>Log</ACTIONS1>
    <CUSTOMACTIONS1>!cen;!clrstack;.dump /ma /u c:\exceptiondump.dmp;gn </CUSTOMACTIONS1>
    <RETURNACTION1>GN</RETURNACTION1>
   </CONFIG>
  </EXCEPTIONS>
</ADPLUS>

After opening a .dmp file with windbg, the most useful commands are:
!clrstack
!dae
!help

1 Comment so far

  1. Martyn Booth October 5th, 2007 7:59 am

    martynwb@googlemail.com

    Hi,
    My web.config root element is:

    The program only works for me if I remove this xmlns reference, leaving just as the root. How can I resoilve this?

Leave a reply

© 2009 Brian Low. All rights reserved.