Unable to add selected web part(s).

When developing webparts within Visual Studio, and using WSPBuilder, I was having some troubles deploying the webpart. 

Well, the WSP solution (feature) would deploy OK, but I couldn’t add it to the page.

The error message was :

“Unable to add selected web part(s).”


Within my Visual Studio project, I have a FEATURE.XML :

<?xml version="1.0" encoding="utf-8"?>
<Feature  Id="E4AE2E3A-F4EA-4f76-8AB1-1EB10A035129"
          Title="SharePointRoot Very Awesome Web Part"
          Description="Does lots of awesome things"
    <ElementManifest Location="elements.xml"/>

This then points to the ELEMENTS.XML :

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="WebPartPopulation" Url="_catalogs/wp" RootWebOnly="TRUE">
    <File Url="Very_Awesome.webpart" Type="GhostableInLibrary">
      <Property Name="Group" Value="SharePointRoot"></Property>
      <Property Name="QuickAddGroups" Value="SharePointRoot" />

The corresponding file containing the “real” details for the WEBPART (typename, etc) is VERY_AWESOME.WEBPART :

  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
      <type name="SharePointRoot.VeryAwesome, SharePointRoot, Version=, Culture=neutral, PublicKeyToken=9ddc3289d104dfbe" />
      <importErrorMessage>Cannot import SharePointRoot VeryAwesome Web Part.</importErrorMessage>
        <property name="Title" type="string">SharePointRoot VeryAwesome</property>
        <property name="Description" type="string">Displays lots of Very Awesome list items</property>


I have a Class library within my project – with the specific logic, etc – and the specific namespace and class library name :

namespace SharePointRoot
    public class VeryAwesome: Microsoft.SharePoint.WebPartPages.WebPart


        …………….        etc.


All the plumbing looks correct – I initially realised I had the WRONG PublicKeyToken for the DLL. 

The value had been copied from another project – but it’s now correct.

  • Re-deploy – and STILL can’t add the WebPart.
  • I un-installed the feature using WSPBuilder – and re-deployed it.
  • Still got the same error – unable to add selected web part(s).

WTF !!?!


To cut a long story short (well – over an hour of fiddling, poking, IISRESET’ing, etc) – it turned out to be the copied value for the PublicKeyToken.

Or more specifically – the WEBPART file within the Web Part Gallery.

When you retract/delete the solution – the WEBPART file does not get deleted.

And – if you make changes to the WEBPART file – it doesn’t get over-written.

And so – even though I had updated the PublicKeyToken, but it wasn’t actually re-deploying the file.

I only discovered this after I (in desperation) changed the text within the WEBPART – to see if the message box would change – and it didn’t…!


If you’re having troubles with NOT being able to add a webpart, maybe manually delete the WEBPART file from the Web Part Gallery – and try to re-deploy it – especially if you’ve had to change the PublicKeyToken, or TypeName, etc – AFTER it’s been initially deployed.

  • Click on Site Actions > Site Settings
  • Click Web Parts
  • Find the WebPart – and click the “Edit” button (on the right)


  • Click “View XML” to see the type name – this is how I noticed the OLD PublicKeyToken value
  • Click the button for “Delete Item”
  • Re-deploy your WSP from within Visual Studio
  • Check the Web Part Gallery to see the updated value/s


Hope that helps – it certainly tricked me for a little bit !


Another great post from Mikhail Dikov has a few other pointers and things-to-try…>

4 thoughts on “Unable to add selected web part(s).

  1. Jonnyb92 August 23, 2011 / 11:35 am

    Thanks very much, I’ve been looking at this for a couple of days I didn’t know where else to look!


  2. ptzedakis December 5, 2011 / 6:33 pm

    Excellent man!! I was going mad until I found your article! Great work!


  3. Rockie May 7, 2012 / 11:55 am

    Mikhail Dikov,
    GREAT! Thank You very very much! 🙂

    I changed WSPBuilder versions, recompiled on x86, x64… Well I searched wrong place) Thank You for solution!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s