August 15, 2012

How to find which W3WP.exe process to debug


When you set break points in SharePoint code, you need to attach the debugger to the w3wp.exe process that is responsible for running your code. The problem is that there are multiple instances of this process, so which one to attach the debugger to?


Run the Windows Task Manager -> View -> Select Columns -> Check ‘PID’ and ‘Command Line’ columns. 
In Processes tab you will see the available w3wp.exe processes along with their IDs and command lines.

Pick the one with a command line referring to ‘SharePoint-80’. That will be your main SharePoint process so get the PID (example: 6512).
Now in Attach to a process windows in Visual Studio, select the process with the aforementioned PID (6512).