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. :)
- Join my session at CTTT25 this week: Level Up Your Teams Extensibility Game with Blazor | Session materials from Cloud Technology Townhall Tallinn 2025! - January 28, 2025
- How to identify which wifi band your Decos are using? - January 21, 2025
- Don’t assign root domain to GitHub Pages if you use it for email! - January 14, 2025