This post was most recently updated on September 30th, 2022.
< 1 min read.Every now and then comes the time when you’d actually need to debug something, and then you’ll likely be using your Visual Studio to attach the debugger to one or more processes.
Using CKSDev to attach to all IIS worker processes (w3wp.exe), or if you don’t use CKSDev, just pressing ctrl+p and selecting the processes from the list, is often a good enough solution. However, sometimes that makes your dev box sluggish, or maybe catches exceptions from code you’re not wishing to debug at the time. And it would be handier to just attach to the one process you actually need. But how to find out the right one? Chances are, you’ll be having 3-6 w3wp processes, and you can only deduce so much from the process id…
Solution
Time needed: 5 minutes
In these cases, appcmd is going to help you. It’s a simple command line utility that helps you find out the correct worker process. To use it, do the following:
- Run cmd as an administrator
- cd %systemroot%\system32\inetsrv
- appcmd list wp
- Fish out the process id from the output
And here you have it! You only need to attach to this single process to actually attach the debugger to the worker process running your custom code. Awesome!
PROTIP: Remember to select “Show processes from all users” in the “Attach to Process”-window – otherwise you’re not going to have much luck trying to locate the process you found in step 4 above. :)
- “Destination Path Too Long” when copying files in File Explorer? Easy workaround(s)! - August 27, 2024
- Where does NetSpot (wifi heatmapping tool) store its project files? - August 20, 2024
- How to fix Bitlocker failing to activate? - August 13, 2024