Monday, October 22, 2012

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 pick the one belongs to the target web application, otherwise, 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!
attach w3wp process visual studio 2010
attach w3wp process visual studio 2010

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)
multiple w3wp.exe task manager 
  • Select the "PID (Process Identifier)" column from the list.multiple w3wp.exe instances Task Manager Find ID
  • Now go to 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.
attach w3wp.exe process visual studio
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.

Happy debugging!

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 command line. If it says "Error - No Results" - Either your IIS sites are in 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 "Command Line" column in view to get the process with its associated web application.



You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...