Wednesday, January 25, 2012

SP2010 content and structure tool error


Scenario:
When users visit the content and structure tool then get an "object reference not set to instance of an object" error. Here is the stack trace,


"Server error in'/' application.
Object reference not set to an instance of an object."

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.SharePoint.Publishing.Internal.WebControls.ObjectSerializer.evaluateTestAutomationId(CachedList cachedListToEval) +48
Microsoft.SharePoint.Publishing.Internal.WebControls.ObjectSerializer.get_AutomationId() +189
Microsoft.SharePoint.Publishing.Internal.WebControls.EcbEnabledTreeNode.RenderPreText(HtmlTextWriter writer) +183
System.Web.UI.WebControls.TreeNode.Render(HtmlTextWriter writer, Int32 position, Boolean[] isLast, Boolean enabled) +7748
System.Web.UI.WebControls.TreeNode.RenderChildNodes(HtmlTextWriter writer, Int32 depth, Boolean[] isLast, Boolean enabled) +962
System.Web.UI.WebControls.TreeNode.Render(HtmlTextWriter writer, Int32 position, Boolean[] isLast, Boolean enabled) +8926
System.Web.UI.WebControls.TreeView.RenderContents(HtmlTextWriter writer) +274
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +41
ASP._layouts_sitemanager_aspx.__RenderForm1(HtmlTextWriter __w, Control parameterContainer) +1011
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +114
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +252
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +86
System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +52
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +239
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +41
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +239
Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.RenderChildren(HtmlTextWriter writer) +57
System.Web.UI.Page.Render(HtmlTextWriter writer) +37
Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.Render(HtmlTextWriter writer) +57
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeSta
Solution:


The content and structure tool is very sensitive to any kind of missing lists or subsites in the site collection. Possibly caused due to Publishing feature activation/deactivation or some other type of corruption


First we need to check if corruption exists using,
stsadm -o databaserepair


This will return the orphaned objects with the corresponding ID and WebID. If it does not return any results then you will have to write some powershell to get all lists in the site collection and check if any of them returns the famous "List does not exist" error when you browse to /site/subsite/_layouts/ListEdit.asps?List={GUID} page


In my case databaserepair returned some lists which were orphaned all from the same subsite.


I took the ID of 1 of the list which was orphaned and fired a SQL query against the content database.


select * from dbo.AllDocs with (nolock) where ListId='listID'


This query also returned the WebID associated with the ListId. In my case all the orphaned sites were from the same web and this web was deleted by an end user and hence it was in the recycle bin.


Here are the steps I am going to take to fix this,
1. Delete the items from the recycle bin and make sure it is completely deleted.
2. Run databaserepair cmd again to test for corruption
3. If everything works out the tool should be working again.

No comments:

Post a Comment