Reminder: Delete Web Parts from Gallery when Changing Version Numbers

Posted Tuesday, March 4, 2008 3:02 PM by CoreyRoth

I have found that when working with web parts one of the most painful experiences is dealing with one when the version of the DLL changes.  This is never fun.   In this case I am assuming you are deploying a .webpart file via feature using a solution package.  If you try to Upgrade the package or Retract the package and then deploy the new version, the installation will be successful.  After reactivating your feature, if you try to use the web part anywhere it will most likely fail (along with all of the other pages you have it deployed on).  This is because the installation of the feature will not delete or update any existing web parts in the web part gallery.  So if you have a .webpart in there already referencing version of your DLL and you want to update it to, it will not change it if it already exists.

The proper way to handle this is to delete the web parts from the gallery before updating.  You can do this manually if you want or even better update your feature deactivation code to go in there and remove the web parts from the gallery.  Honestly, this goes for anything you are deploying via feature in SharePoint.  Just because you deactivate your feature, don't expect it to go back and remove whatever you added.  You are always going to have to write something to delete a file, document library, navigation item, page, etc.

Filed under: ,


No Comments

Leave a Comment