Omicron Llama

Coding all day, every day.

SharePoint 2010: Migrating solutions from SharePoint 2007 – A Caveat

We’re working on a large(ish) project right now in SharePoint 2007 that will quite soon be migrating to SharePoint 2010, so I decided to take the WSPs we’ve had so far (that work fine in 2007) and see how well they’d work in 2010, either as Farm solutions or User (Sandbox) solutions.

I came across an interesting play in behaviour.

The project in particular isn’t uncontrollably big, but it’s growing in size and there are 4 of us developers working on it. It turns out that there is a Field element (a site column) being declared twice in an Elements Manifest (elements.xml) file. Why hadn’t we spotted this? Because it deploys fine, without error in SharePoint 2007.

Here’s where the interesting bit comes in…

I decided to create a new project in Visual Studio 2008 destined for SharePoint 2010 consisting of a dead simple feature that deploys one site column – but declares it twice. Here’s the solution’s structure in Visual Studio, ready for packaging with WSPbuilder:

And here’s the Feature and Elements.xml contents (excuse the loss of Case, think my syntax highlighter messes up formatting a bit too much):

And the Elements…

So what happens?

Well when you deploy this to SharePoint 2007, and activate the Feature at site collection level – it works without fault. Great!

When we take the WSP and upload it to the Solution Gallery of a SharePoint 2010 site, again it works fine (Site collection features from user solutions seem to be activated automatically on my system, not sure if this is normal).

But, add this solution as a Farm solution in Central Administration, deploy then activate from Site Collection Features and you’ll get this error…

So Beware! If you intend your solutions developed for 2007 to work as Sandboxed solutions, give them a sanity check by testing the deployment on your development system as a Farm solution first – as it appears to have more stringent validation of Feature elements than the User Code environment.

Leave a Reply

Your email address will not be published. Required fields are marked *