Wednesday 7 April 2010

SP2010 support and fixes for SharePoint Content Deployment Wizard

I’ve released an updated version of the Content Deployment Wizard to Codeplex (version 2.8) – this version supports SharePoint 2010. The Content Deployment Wizard is my reasonably popular tool for moving content around in your SharePoint environment(s) – if you haven’t come across this before, you can select site collections, webs, lists, folders, files or list items to export to a file for import somewhere else:

SharePointContentDeploymentWizard

There are two purposes of this release:

  1. Fix the ‘Object reference’ error commonly experienced with the previous version (2.7)

    It took me some time to realize, but this happened very frequently and if you used 2.7 often you may well have seen this issue - apologies. It seems this was introduced by Alex in the code he contributed to that release, but it was an unusual threading bug and frankly I’m sure if I’d have written the code it would probably have hit me too! Thanks again for your contribution Alex.

  2. SharePoint 2010 support

    OK so I bent the truth somewhat at the beginning of the article – in fact all versions of the tool already support SharePoint 2010. This is because there are no breaking changes in Microsoft’s API which my code uses between 2007-2010, so all that’s required is a couple of entries in the .exe.config file to redirect the assemblies which are picked up. However it’s difficult to convey that message in the title or first sentence of this article, and I’m finding that folks who don’t understand the concept of .Net assembly redirection just don’t believe I didn’t have to ‘create a new version with support for 2010’ :) That said, I have made a couple of improvements to make it easier:

    - the 2.8 installer adds the appropriate BindingRedirect entries into the config file for you, but commented out. Simply uncomment these if you are installing on SP2010
    - the 2.8 installer correctly installs the stsadmcommands.COB.SPDeploymentWizard.xml file to the 14\CONFIG directory if it exists (i.e. because SharePoint 2010 is installed) to ensure the STSADM commands work

    For reference, the .exe.config file entries which are required for SP2010 are:
    <!-- Uncomment this section to use the Wizard with SharePoint 2010 - this will ensure the SharePoint 2010 assemblies are used. -->
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
                <assemblyIdentity name="Microsoft.SharePoint" publicKeyToken="71e9bce111e9429c" culture="neutral" />
                <bindingRedirect oldVersion="11.0.0.0" newVersion="14.0.0.0" />
            </dependentAssembly>
            <dependentAssembly xmlns="urn:schemas-microsoft-com:asm.v1">
                <assemblyIdentity name="Microsoft.SharePoint.Publishing" publicKeyToken="71e9bce111e9429c" culture="neutral" />
                <bindingRedirect oldVersion="11.0.0.0" newVersion="14.0.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    N.B. If you wondering about the version range starting at 11.0.0.0 rather than 12.0.0.0, this is the pattern Microsoft use themselves in their BindingRedirects.
The 2.8 version of the Wizard can be downloaded from http://spdeploymentwizard.codeplex.com/releases/view/42380 – please let me know if you run into an issue, whether on SharePoint 2007 or 2010.