Unexpected System.NullReferenceException After Restoring a SharePoint 2010 Content Database

After a user deleted lots of permissions on a SharePoint site we decided to ask for a restore of the content database in order to solve the issue.

Everything was fine, we had all the backups, we knew the time the user deleted the permission assignments and the had the downtime window to restore the backup.

The restore process went fast and fine, the database has been restored and I attached it back to SharePoint.

I tested the site on one of the WFE servers and it looked great, but when I went to the second load balanced server I got the following error message:

Unexpected System.NullReferenceException: Object reference not set to an instance of an object.

at Microsoft.SharePoint.SPSite.PreinitializeServer(SPRequest request)
at Microsoft.SharePoint.SPWeb.InitializeSPRequest()
at Microsoft.SharePoint.WebControls.SPControl.EnsureSPWebRequest(SPWeb web)
at Microsoft.SharePoint.WebControls.SPControl.SPWebEnsureSPControl(HttpContext context)
at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.GetContextWeb(HttpContext context)
at Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.PostResolveRequestCacheHandler(Object oSender, EventArgs ea)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& complet…

It didn’t make any sense. Why only one of the servers was not working?

I tried the regular debug approach but none of the actions worked:

  • Restart the application pool.
  • Reboot the server.
  • Attach and dettach the content database.

I also tried to connect to the SPWeb using Powershell and it worked on one server and didn’t work on the other one.

I went then to Google to research a little bit and after several false positive articles, I found this article explaining the issue (thank you very much Giles!!!):


SharePoint has a configuration cache and if it is not cleared you can have this kind of issue.

Follow the steps to solve the issue:

  1. Stop the OWSTIMER service on the problem SharePoint WFE server in the farm.
  2. On the problem server, navigate to:

    Windows Server 2003 location: Drive:\Documents and Settings\All Users\Application Data\Microsoft\SharePoint\Config\GUID and delete all the XML files from the directory.
    Windows Server 2008 location: Drive:\ProgramData\Microsoft\SharePoint\Config\GUID and delete all the XML files from the directory.

  3. Delete all the XML files in the directory. NOTE: ONLY THE XML FILES, NOT THE .INI FILE.
  4. Open the cache.ini with Notepad and reset the number to 1. Save and close the file.
  5. Start the OWSTIMER service on the server and wait for XML files to begin to reappear in the directory.
  6. IIS Reset (optional) – you can just recycle the app pool and it will work.


Thanks @twlamb for the revision…..

See you,



9 Responses to Unexpected System.NullReferenceException After Restoring a SharePoint 2010 Content Database

  1. Giles Hamson says:

    I know this issue drove me and my colleagues a bit crazy until we worked it out. Glad we could help.

    Kind Regards


  2. Petter says:

    Thank you very much! Worked like a charm!

  3. Pingback: Broken Reference to SharePoint 2010 Content Database « myspworld

  4. fidy13 says:

    Thanks a lot! This article saved my day 🙂

  5. cyberprune says:

    Thanks, I ran into this problem while migrating content between 2007 and 2010 farms with AvePoint’s DocAve. The timer job cache clear was the answer to fix the problem.

  6. Åse says:

    I love you… Worked as a charm!

  7. Bodhidharma says:

    Another sarisfied customer here. Thank you for posting this!

  8. Thanks, it worked!!!

  9. Jay says:

    Awesome!! worked great!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: