Skip to content

May 2, 2010

Don’t Deactivate that Site Template Solution

It’s open season for hunting down SharePoint 2010 bugs and I’ve found a particularly ugly one. I created a site from a site template, and when I went in to the solution gallery and deactivated the solution (after the site was created) the solution gallery began throwing an exception:

[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.SharePoint.WebPartPages.ListViewWebPart.PrepareContentTypeFilter(SPList list, Hashtable[] excludedTransformers) +176
Microsoft.SharePoint.WebPartPages.ListViewWebPart.GenerateDocConvScriptBlock(SPWeb web, SPList list) +482
Microsoft.SharePoint.WebPartPages.ListViewWebPart.OnPreRender(EventArgs e) +1957
Microsoft.SharePoint.WebPartPages.WebPartMobileAdapter.OnPreRender(EventArgs e) +78
System.Web.UI.Control.PreRenderRecursiveInternal() +11025422
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Control.PreRenderRecursiveInternal() +223
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3393

The specific steps are really simple…

  1. Create a blank site.
  2. Save site as a template.
  3. Create a new site collection but don’t establish a template
  4. Upload the template created in step #2 to the solution gallery and activate
  5. Create the site with the template.
  6. Go to the solution Gallery and deactivate the solution.

If you want or need to get back to a partially useful state you can do the following steps in the SharePoint Management Shell..

$site = get-spsite http://localhost/sites/mysitehere
$solutions = $site.Solutions
$solutions.Add(1)

The moral to this story is don’t deactivate the site template that you created a site from (at least not at the moment). In SharePoint 2007 you could remove a site template’s STP file once the site was created because the STP file was essentially a macro that replayed the creation steps over the existing site definition. However, this isn’t the case with the new WSP format. The source of the items including content types is tracked, and may be removed if you remove the site template.

Recent Posts

Public Speaking