Compartilhar via


Debugging W3WP Startup

On a few occasions, I have needed to debug the startup of the IIS worker process (w3wp).  I finally decided to create a script so that I no longer need to search for the answer.  The script starts w3wp by requesting a non-existent ASPX page.  After windbg is closed, the script will kill the debug session and clean up the registry.

Script requirements:

Debug Script:

reg add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\w3wp.exe" /v Debugger /t REG_SZ /d "cdb.exe -c \".server tcp:port=9999\"" /f
iisreset /restart
start /b tinyget5 -srv:localhost -uri:/notfound.aspx -status:404
sleep 3
windbg -remote tcp:port=9999,server=localhost
pskill cdb
pskill w3wp
reg delete "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\w3wp.exe" /f

UPDATE:

If you are setting managed breakpoints, you will want to break when the managed assembly loads using "sxe ld:Assembly". For instance, "sxe ld:clr" or "sxe ld:System.Web.dll".

If you want to debug compilation, you should delete the "Temporary ASP.NET Files" under the framework installation folder for your website after the iisreset.