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,