Monday, August 11, 2008

Debugging SharePoint Web Part-I

In my earlier post I touched how to develop SharePoint web part using VS.NET. Now we'll walk through debugging our web part, can you imagine? you are developing .NET project so all facilities you used to be found in programming websites are available in sharepoint webpart development.

There are 2 cases right here:

  1. Debugging Web Part has been developed on your sharepoint site server.

  2. Debugging Remotely Web Part has been developed on your local machine.
*First :Debugging Web Part has been developed on your sharepoint site server:
  1. To be able to debug your code(web part) you need to verify that your webpart DLL located at website BIN directory(in our case"C:\Inetpub\wwwroot\wss\VirtualDirectories\1234\Bin").
  2. Verify your assebly is registered as safe control at web.config file - If you want to deploy your webpart to "http://sp:1234/" you should modify web.config file of this site "C:\Inetpub\wwwroot\wss\VirtualDirectories\1234\web.config"- to know how to do this kindly open up this link.

  3. Open up your Webpart project in VS.NET.
  4. Set breakPoint wherever you want in your code.

  5. Select from Debug menu --> Attache to Process.
  6. Pop up box will appear listing all current running processes, select Process "w3wp.exe". may be you will see more than one from this process, select the one running with your username appear in User Name column.
  7. Now you are ready to debug your application.
  8. Get back to your page you deploy this webpart.
  9. As soon as you open the page contains the wepart, your cursor automatically goes to VS.NET project (webpart project) and will stop at your code line you set break point at.
  10. Effortless and useful.

wait for second will be soon.

No comments: