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’d 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…
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. 🙂
Latest posts by Antti K. Koskela (see all)
- How to fix an Office Group with no Owners - November 14, 2018
- Help! My “Content and Structure” page in SharePoint Online is gone! - November 7, 2018
- Thanks for coming to my session at SPS New England 10/20 ! - October 20, 2018
- Speaking at SPS New England on 10/20! - October 17, 2018