Tracking NullReferenceExceptions in sitecore

I am trying to track the NullReferenceException that occurs on sitecore 6.5 when loading any webpage:

[NullReferenceException: Object reference not set to an instance of an object.] Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +133 Sitecore.Diagnostics.Log.Error(String message, Type ownerType) +45 Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +680 Sitecore.Configuration.Factory.LoadAutoIncludeFiles(XmlNode element) +63 Sitecore.Configuration.Factory.GetConfiguration() +347 Sitecore.Diagnostics.LoggerFactory..cctor() +67 [TypeInitializationException: The type initializer for 'Sitecore.Diagnostics.LoggerFactory' threw an exception.] Sitecore.Diagnostics.LoggerFactory.GetLogger(Type type) +17 Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +93 Sitecore.Diagnostics.Log.Error(String message, Type ownerType) +45 Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +680 Sitecore.Configuration.Factory.LoadAutoIncludeFiles(XmlNode element) +63 Sitecore.Configuration.Factory.GetConfiguration() +347 Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert) +82 Sitecore.Configuration.Factory.GetConfigNode(String xpath) +29 Sitecore.Resources.Media.UploadWatcher.InitializeIgnoreList() +114 Sitecore.Resources.Media.UploadWatcher..cctor() +51 [TypeInitializationException: The type initializer for 'Sitecore.Resources.Media.UploadWatcher' threw an exception.] Sitecore.Resources.Media.UploadWatcher..ctor() +0 [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) +98 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241 System.Activator.CreateInstance(Type type, Boolean nonPublic) +69 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23 System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60 System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +231 System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1365 Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleReflectionUtil.GetIntegratedModuleCollection(HttpApplication target, IntPtr appContext) +33 Microsoft.Web.Infrastructure.DynamicModuleHelper.CriticalStatics.Init(HttpApplication context) +179 Microsoft.Web.Infrastructure.DynamicModuleHelper.IntegratedDynamicModule.Init(HttpApplication context) +6 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +517 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +194 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +339 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +253 [HttpException (0x80004005): Exception has been thrown by the target of an invocation.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9087676 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256 

interesting features that make tracking this error difficult are:

1) I get the following error in the sitecore log:

 Exception: System.InvalidOperationException Message: 'analytics' connection string is not defined Source: Sitecore.Kernel at Sitecore.Diagnostics.Assert.IsNotNull(Object value, String message) at Sitecore.Diagnostics.Assert.ResultNotNull[T](T result, String message) at Sitecore.Analytics.Data.DataAccess.DataAdapters.DataAdapterManager.ConnectionStrings.get_AnalyticsSettings() at Sitecore.Analytics.Data.DataAccess.DataAdapters.DataAdapterManager.ConnectionStrings.get_Analytics() at Sitecore.Analytics.Data.DataAccess.DataAdapters.Sql.SqlServer.SqlServerDataAdapterProvider..ctor() 

however analytics is very well disabled:

 <setting name="Analytics.DisableDatabase" value="true" /> ... <setting name="Analytics.Enabled" value="false" /> 

2) the error disappears when I debug the visual studio, join IIS and hit at least one breakpoint (if I did not hit the breakpoint, the error remains)

3) the error appears again when I do the assembly, or tap web.config. They didn’t try to rebuild, as this will remove important sitecore plugins from / bin

more information about my environment: visual studio 2010, IIS 7, sitecore 6.5, windows 7

How do you track this error?

+6
source share
9 answers

Well, after half a day of debugging and decompilation, I found out that the problem was in the (internal) Sitecore.Configuration.ConfigPatcher class, it seems to be choked with Sitecore.WebDav.[Debug/Release].config files, which are used for xdt conversions of the Sitecore.WebDav file .config for the content delivery and content creation environment.

Currently, a workaround is renaming these files (and disabling xdt conversions)

However, this problem should affect any user of xdt conversions for files other than web.config (I use a slow cheetah add-in)

+4
source

You may also get this error when you have an empty configuration section in a patched configuration file, for example

 <?xml version="1.0"?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> </configuration> 
+4
source

I had something similar when adding xml comments between nodes:

Does not work:

 <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <!-- not used in a delivery node --> <sitecore /> </configuration> 

If you add a comment before the root of the node, it will work.

 <!-- not used in a delivery node --> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore /> </configuration> 
+2
source

It appears that there is no "include" configuration file in the configuration. Decompile Sitecore.Resources.Media.UploadWatcher.InitializeIgnoreList to try and decide which one (sorry, you don't have a decompiler). Reflector comes with a 30-day trial version or simple Telerik decompilation for free.

EDIT I am using a product called SlowCheetah , which converts XML transformations based on assembly configuration for any XML file, and not just web.config, like VS. You can NuGet. Highly recommended.

+1
source

I had the same problem, I found out that there is no <sitecore> node in your configuration files, you will get such an error!

+1
source

I would start by removing Sitecore.Analytics.dll from the bin folder of your site. You do not need a DLL because you have disabled analytics, but as you can see from your stacktrace, there is an error inside this DLL.

0
source

I had a similar problem and it turned out that I had the wrong configuration file. In particular, I had to insert some random line at the beginning of the configuration file:

 some_random_string<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> 

After removing redundant characters, the problem was resolved.

However, changing the name of the problem file also resolves the exception.

0
source

I had the same problem (my stack trace was the same as the output), and it turned out to be an incorrect .config file in the App_Config\Include folder. Fixed a problem with the configuration and my site without any problems.

0
source

I had the same problem that we encountered above, and we can confirm that this happened due to an incompatible .config file in the App_Config / Include folder. The .config file worked with IIS7, but not II6.

My best advice to understand the essence of this problem is a tedious trial and error message. Remove any suspicious .config files until the website is up (or back to the original .config files). Start adding each .config file one by one until you find a file that crashes the site and causes the above problem.

0
source

Source: https://habr.com/ru/post/910095/


All Articles