This post is a tip on how to debug a SharePoint Project in Visual Studio on IIS 7 web server. Obviously, the easiest way is to hit F5 in Visual Studio and start debugging. But, that is not always possible, because using F5 builds your application and deploys is again. And you may not want to do that due to various reasons.
The other way is to use “Attach to Process” option in Debug menu. The problem here is when you open the “Attach to Process” window, you see lot of w3wp.exe processes and you really don’t know which process to attach the debugger to. So we end up attaching the debugger to all the processes. Here is how to get hold of the process that you want to debug.
- Open IIS (type inetmgr in the search box on the start menu). This opens the below window.
- Click on the Worker Processes button shown in the red box in the above figure. This will list all the worker process running on the IIS Server.
- Look for the Application Pool name you want to debug. Remember the Process Id corresponding to it.
- In Visual Studio, in Debug menu, click on the “Attach to Process” option. This will open the Process window. Search for the Process Id of the Application Pool. Make sure you check the options below if you are running the application on different machine or as different user. Select the process and click on the Attach button. This will prompt a security warning. Select attach on the pop-up, and you are all set to debug.