Deploy and Debug a Webpart to your SharePoint Server

Deploy and Debug a Webpart to your SharePoint Server

To deploy a Webpart to a SharePoint Installation, complete the 3 steps beneath:

  1. Copy the dll from your Webpart to the bin folder of a webapplication
  2. Register the dll in the web.config as safe
  3. Add the Webpart to the Webpartgallery of a sitecollection
  4. Debug the Webpart

Copy the dll from your Webpart to the bin folder of a webapplication

Copy your dll to the bin folder of your IIS virtual server directory. In my case this is "C:\Inetpub\wwwroot\wss\VirtualDirectories\45079\bin".

If you don’t know where this directory might be, look it up in the IIS Manager.

Register the dll in the web.config

Open the web.config (e.g. "C:\Inetpub\wwwroot\wss\VirtualDirectories\45079\web.config"). Find the <SafeControls> section, and add a line like:

<SafeControl
Assembly="simple Webpart HOWTO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=2e6fe95c9937e6f4"
Namespace="simple_Webpart_HOWTO"
TypeName="*"
Safe="True" />

The Assembly Name and the Namespace can be found in the properties of your project:

Add the Webpart to the Webpartgallery

Go to the Webpartgallery from your sitecollection, and add the new Webpart to your Webpartgallery.

Now you are done J You can add the new Webpart to every site in your sitecollection.

Debug the Webpart

To be able to debug a Webpart, you have to copy the dll (which was compiled in debug mode) and the pdb to the bin folder of your virtual server.

The easiest way is to set the output path for your debug configuration in the VS to the bin folder (step one from this post).

  1. Set the output path

  1. Build your Webpart
  2. Attach the VS to the Application Pool which the SharePoint site uses
    If you are unsure which w3wp you should attach the VS to, you can look it up in the IIS Manager. You can find the user in the application settings from your virtual server.

 

 

 

 

  1. Set a breakpoint and reload the site in your browser

Caution:

  • Every time you deploy your Webpart, the application pool will recycle. So deploy with care, or – better – use a testsystem to develop and test your webparts.
  • While your breakpoint is active, the whole application pool will stop executing requests to every website, which uses that application pool.
2 Comments

Paul Aviles

Reply

Does this works on WSS 3?

I cannot manage to follow the Webpart to the Webpartgallery.

Thanks

Paul

 

    René Hézser

    Reply

    Hi Paul,
    this post is 8 years old. Nowadays there are different ways to deploy WebParts.
    Please take a look at the SharePoint SDK to see how it works.

    René

     

Leave a Reply