Themes Gallery missing in SharePoint 2010 Site after Visual Upgrade

Themes Gallery missing in SharePoint 2010 Site after Visual Upgrade

Recently while working with one of my colleagues (Renzo) to migrate a SharePoint 2007 content database to SharePoint 2010 we came across this issue. After migrating the content database we could successfully access the site in SharePoint 2007 mode (UI version 3) and it was using the custom theme.

I should mention at this point that the sites inside the content database were using a custom developed theme. Before starting the migration we deployed the wsp containing the theme on the SharePoint 2010 farm.

We then proceeded to hit the Visual Upgrade option to take the UI from v3 to v4. The UI appeared to upgrade successfully with no errors. However when we tried to change the theme using Site Settings > Theme the page bombed out and would not display the error message.

After rooting around in the event viewer and SharePoint logs we found this error:

Exception information:
    Exception type: NullReferenceException
    Exception message: Object reference not set to an instance of an object.
Thread information:
    Thread ID: 9
    Thread account name: DomainOurAccount
    Is impersonating: False
    Stack trace:    at Microsoft.SharePoint.ApplicationPages.ThemeWebForm.<>c__DisplayClass2.<LoadV4Page>b__0()
   at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()
   at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)
   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)
   at Microsoft.SharePoint.ApplicationPages.ThemeWebForm.LoadV4Page()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The error message wasn’t actually very helpful so we ended up reflectoring out the code in the Microsoft.SharePoint.ApplicationPages assembly and writing a small console application to give us better error handling.

It turned out that SharePoint couldn’t find the theme folder which should in _catalogstheme. Somehow this gallery had gone missing. After a long while trying to copy the gallery from another site that was successfully working we gave in and decided to do the migration again. This time however we switched the theme in UI version 3 mode to the default theme and then hit the visual upgrade.

The UI upgraded successfully and the Theme gallery was present –we were now able to change the theme of the site with no spurious error message.

I’m not sure if this is a bug but I can safely say that as a best practice the theme should be switched before the visual upgrade takes place.

Hope this helps! Smile

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">