[SPC09] Upgrading SharePoint 2007 Code to SharePoint 2010

October 22, 2009

This was my last session at the SharePoint Conference 2009 in Las Vegas. Tomorrow I fly back to the real world :-( At least, I splashed up a little at the Mandalay Bay Beach Wave Pool.

This session was very instructive, too. It versed about how to migrate existing SharePoint 2007 code and projects into SharePoint 2010 world. The presenter was a New Zealand guy called Chris JT Auld, from Intergen Limited. Here are my notes on that:

Upgrading existing VSeWSS projects

VS2010 template (a .VSIX file) allow import VSEWSS 1.1 and after into VS2010. It recreates the project structure only. You should do some refactoring around the solution structure, as VSEWSS had a 1:1 feature-artifact relation. New Feature Designer is more flexible that the VSEWSS, it now allows you to have more artifacts in a single feature.

There are several issues that may arise:

  • STP files are not supported anymore. You will have to vreate V3 site, upgrade to V4, fix issues and then save as template into WSP
  • UI Changes: the backwards-compatible UI (no ribbon, no in-place wiki edits, no interactive calendars). There are now "versioned controls" that are aware of the version-specific content. The UIVersionControl has an UIVersion attribute, and the version-specific content will honor the correct version and be shown. It allows to supress the rendering of a version-specific markup.
  • CSS has changed completely. Any customizations on CSS or master pages will have to be redone. The new UI is fully XHTML and WCAG 2.0 AA level compliant.
  • No more toolbars in the new UI. All the custom toolbar actions go to "Custom commands" on the Ribbon
  • Actions with codebehind code are not migrated automatically, they will have to be redone.
  • Queries that return large number of results may fail. You might have to adjust the thresholds through the Central Application and catch the exception in the code and treat it. The limit applies only to the non-admin users, so tests should be done with a non-admin user. An index on the queries columns should be made to ensure that all items should not be scanned when executing the query. The query limit override can be done by code but it has to be allowed by the administrator.

Upgrading custom code for SharePoint

Any code that runs in IIS should need no recompilation. The code that runs in the Timer Service must be recompiled. The code outside SharePoint will have to be recompiled or redirected using bindingAssembly declarations.

Many APIs have been deprecated. In most cases it will give you a warning during the recompilation but it should work. Examples: SPFarm.Create now uses SPFarm.Create(passphrase), SPVirtualServer is deprecated by SPWebApplication. A Reflector add-in will be made by Chris to scan an assembly for deprecated code.

Any hard-coded path to "12" hive must now point to the new "14" hive.

There have been numerous improvements in the WSP solution upgrade process:

  • BindingRedirects are now supported in the manifest file
  • Features can be upgraded declaratively and programmatically
  • You can query the farm (QueryFeatures method) to see what features are there and which version are they, so they can be upgraded by code (SPFeature.Upgrade method). The version range element in Feature.xml allows for upgrading from multiple versions.
  • STSADM command for solution upgrade (upgradesolution) is also available. For more granular upgrade, object model will have to be used.
  • In the object model, there's a FeatureUpgrading event where to add the upgrade code. Be careful to check for the right version-dependant upgrade action to be called.
  • To upgrade the feature for new instances, ,use STSADM -upgradesolution. For upgrading the instances already created , psconfig cmd upgrade -inplace -b2b command should be run.
  • Sandboxed solutions can be upgraded by uploading a new versions and choosing "Upgrade" from the UI.

A complete whitepaper was released on Monday, called "Redeploying Customizations and Solutions in SharePoint Foundation 2010 and SharePoint Server 2010". It's avaliable on http://msdn.microsoft.com/en-us/library/ee662217%28office.14%29.aspx


Profile picture

Written by Edin Kapić Insatiably curious code-writing tinkerer. Geek father. Aviation enthusiast. Cuisine journeyman. Follow me on Twitter