Blog - Robert Bogue [MVP]
Rob's Notebook
SharePoint Calendar

Categories

Links

Archives

Other Blogs

Thor Projects LLC - Welcome : Blog - Robert Bogue [MVP]

Don’t Deactivate that Site Template Solution

Posted by Robert Bogue on Sunday, 2 May 2010 07:22 | 1 Comments |

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.

Comments

Sunday, 2 May 2010 07:42 by Todd Bleeker
The reason for this is rooted in the change from an STP file to a sandboxed WSP CAB. The 2003/2007 STP was simply a "macro" on top of one of the existing Site Definitions on the Farm. So, new sites provisioned from an STP were dependent on the Site Definition, thus the STP was no longer needed. In 2010, the Site Template WSP is actually a custom Site Definition. So, new sites provisioned from from a WSP are dependent on the WSP's Site Definition, thus the need for the WSP to remain activated.

Leave your own comment

Name

Url

Email

Comments