There are two ways to gather data in a Deadlock situation.  If you are using Windows 2003 or later (IIS 6.0 or later), then follow the steps in the KB 828222

If you are using an older version of IIS, then follow the steps below:

Before the issue occurs

A. Download DebugDiag:
======================

  1. Install the Debug Diagnostic tool
  2. The default installation location for the package is C:\Program Files\DebugDiag. It can be changed.
  3. Make sure any other monitoring and debugging tools are not running.

B. Create a Performance Monitor log:
====================================

  1. Expand Performance Logs and Alerts
  2. Right Click on Counter Logs
  3. Choose New Log Settings...
  4. Enter a descriptive name
  5. Note the log file location for later (or go to the Log Files tab and change the location)
  6. Click the Add button
  7. Click the All Counters and All Instances radio buttons
  8. Select the following from the Performance Object dropdown, being sure to Add each one as you select it:
    • Process
    • Thread
    • Processor
    • Memory
    • .NET CLR Data
    • .NET CLR Exceptions
    • .NET CLR Interop
    • .NET CLR Jit
    • .NET CLR Loading
    • .NET CLR LocksAndThreads
    • .NET CLR Memory
    • .NET CLR Networking
    • .NET CLR Remoting
    • .NET CLR Security
    • ASP.NET
    • ASP.NET Applications
  9. Click Close
  10. Click OK

For the ASP.NET counters, select the version that you are wanting to monitor. Ex. For 1.1 framework, select ASP.NET v1.1.4322 and ASP.NET Applications v1.1.4322.

Note: For more information on Performance monitor, see KB 248345

C. Running the 1.0 version of the framework?====================================

If you are running the 1.0 version of the framework you need to do the following before continuing:

  1. Install .Net framework 1.0 SP2 (Skip this step if you are running .Net Framework 1.1)

    SP2 of .Net framework 1.0 can be downloaded from: http://msdn.microsoft.com/netframework/downloads/sp/download.asp
  2. Install the hotfix 329956. This fix resolves an issue of the process recycling due to a false deadlock.

D. Configure server to capture Deadlock
================================

Add the following registry key. This was added to the .NET Framework so that a breakpoint exception will be thrown when the deadlock occurs. This is documented in the following article:

325947 Event ID 1003 with ASP.NET Deadlock

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
DWord: DebugOnDeadlock
Value: 2

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET
DWord: UnderDebugger
Value: 0

E. Configure DebugDiag
===================

Configure DebugDiag to capture the memory dump when the BreakPoint Exception is thrown and when the process stops.

  1. Open DebugDiag
  2. On the Rules tab, click Add Rule
  3. Select Crash and click Next
  4. Select All IIS Processes and click Next
  5. Click Advanced Exception Configuration
  6. Click Add Exception
  7. Select Breakpoint Exception, change Action Type to Full UserDump
  8. Click OK
  9. Click Save and Close
  10. Click Advanced Breakpoint Configuration
  11. Click Add Breakpoint
  12. Select KERNEL32!ExitProcess and change Action Type to Full UserDump
  13. Click OK
  14. Click Save and Close
  15. Click Next through the rest of the wizard

After the issue occurs

The memory dump will automatically get captured when the Deadlock occurs.

A. Stop the Performance Monitor log
===================================

In Performance Monitor:

  1. Right click on your log that is now listed under Counter Logs
  2. Choose Stop Log

kick it on DotNetKicks.com