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. :)
- Windows Search not finding anything? That might be the default now, but you don’t need to accept it! - March 25, 2025
- “The Copilot key isn’t connected to an action. Choose what you’d like to happen when you press the Copilot key” - March 18, 2025
- How to remove Skype for Business, if it sneaks back onto your machine? - March 11, 2025