Debugging SharePoint Webpart from VS 2008

Visual Studio 2008 extensions for Sharepoint greatly ease the process of developing custom Sharepoint solutions. The extension provides a set of visual studio templates for rapid creation of Sharepoint Web Parts, Content Types, Modules etc. You can download the extensions from this Microsoft link.

This blog entry details the steps involved in debugging a web part created using visual studio 2008 web part template. The steps listed are for the scenario where Sharepoint and visual studio exists on the same machine.


1. Develop the Sharepoint web part using VS 2008 web part project template.
2. Deploy the web part. With VS 2008 you don’t have worry about manifest and WSP files. Just right-click on the project name in solution explorer and select Deploy.
3. Add the web part to a Sharepoint page.
4. Set up breakpoints in your web part code. This similar to setting up breakpoints in any .Net code.
5. Attach debugger to ASP.Net worker process (w3wp.exe)

a. From the VS 2008 Debug menu select Attach to Process option
b. From the list of running processes that show up select w3wp.exe and click Attach button.

c. If a recent iisreset was performed on your machine, you must navigate to the Sharepoint site to create a new instance of w3wp process.
d. Sometimes you may also find multiple w3wp process showing up in the Attach Processes list. In such situations you can follow any of the below methods

i. Attach debugger to all w3wp.exe processes. This will ensure that you attach to the process that is running your web part.
ii. You can kill all the w3wp.exe processes by using iisreset /noforce from the command line and navigating to the Sharepoint site to create a new w3wp instance.

6. Navigate to the Sharepoint page which contains the web part you want to debug.
7. As the page starts rendering, control will be transferred to the visuals studio code editor with the execution stopping at first break point.
8. You can continue debugging as with any .Net code.

If you are not able to lay hands on a machine that has Sharepoint and VS 2008 installed, you can download virtual PC image from


Happy debugging