Pick the right w3wp.exe to attach among Multiple Worker processes while debugging
When multiple web applications running with multiple application pools, they will create multiple worker processes (W3WP.exe). While debugging code from Visual Studio, we got to pick the one that belongs to the target web application, otherwise, the debugger will not stop on break-points!
Don’t forget to select “Show processes from all users”, otherwise w3wp won’t be showing up in attach process window!
How to select the correct W3WP.exe to attach?
If you use different user accounts for different application pools, you can just pick the right one easily by checking “User Name” column. Follow these instructions to find the right worker process to attach:
- From the running processes, we’ll have to get the process id value. Lets go to Windows Task Manager >> View >> Select Columns (You’ll see multiple w3wp.exe in task manager)
- Select the “PID (Process Identifier)” column from the list.
- Now go to the command prompt, go to the directory “C:\windows\System32\Inetsrv”
- Enter “Appcmd list wp”
This will list all running worker processes and their associated web applications. Now open the Task Manager to match the PID with the desired web application’s worker process ID.
Now you have the right w3wp process to attach!
Here I have my custom code deployed in the web application “SharePoint80” and wanted to debug the same. So the W3WP process I’ve to attach is 2372.
For Windows 2003 – IIS 6:
If you are running IIS 6 in Windows 2003, You can get the list of worker processes with their associated web applications by running the vb script: iisapp.vbs located at: c:\windows\system32 folder.
You can type cscript iisapp.vbs in the command line. If it says “Error – No Results” – Either your IIS sites are in a Stopped state or no worker processes running.!
Alternatively, You can use Process Explorer from Microsoft to get the right worker process. Make sure you are selecting the “Command Line” column in view to get the process with its associated web application.