Sitecore Prefetch configuration fails to load

Issue:

One day I was uprading my website to Sc 8.2 u2 and after all the steps were done, my sitecore couldn’t load, showing this exception:

[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.Xml.Patch.XmlDomSource.get_NamespaceURI() +3
   Sitecore.Xml.Patch.XmlPatchHelper.MergeNodes(XmlNode target, IXmlElement patch, XmlPatchNamespaces ns) +118
   Sitecore.Configuration.ConfigPatcher.ApplyPatch(TextReader patch, String sourceName) +133
   Sitecore.Configuration.ConfigPatcher.ApplyPatch(String filename) +92
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +176

[ConfigurationException: Could not load configuration file: \Website\App_Config\Include\Prefetch\Common.config.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +379

[ConfigurationException: Could not scan configuration folder \Website\App_Config\Include\Prefetch for files.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +581
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +257

[ConfigurationException: Could not scan configuration folder \Website\App_Config\Include\Prefetch for files.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +480

[ConfigurationException: Could not scan configuration folder \Website\App_Config\Include for files.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +581
   Sitecore.Configuration.ConfigReader.GetConfiguration() +655
   Sitecore.DependencyInjection.ServiceLocator.ConfigureServiceProvider() +29
   Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +153
   Sitecore.DependencyInjection.SitecorePerRequestScopeModule..ctor() +13

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +138
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +105
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1481
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +191
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +27
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +82
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +229
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1114
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +140
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +716

 

I was not able to understand what’s wrong! All of my prefetch configs were fine and identical to ones from the vanilla instance…

So, I started digging into the sitecore patching code. Everything seemed fine, I mean, it is solid and straightforward. I was hopeless, but then…

Solution:

I realized that my Prefetch folder has moved under the /Include folder!

\App_Config\Include\Prefetch\Common.config

And that caused the issue with incorrect patching!

So, in order to fix that, I just had to move it back to /Include, and it worked.

One thought on “Sitecore Prefetch configuration fails to load

  1. It appears if you put a configuration file, that patches something above the node, to the /Include folder. In your example, it is Prefetch/Common.config, but it can be any other file.

    Like

Leave a comment