0

I am migrating from Sitecore 8.1 to Sitecore 9.1 and I'm getting this weird error:

Unexpected object type created from configuration node. 
  Expected: Sitecore.ExperienceAnalytics.Core.Diagnostics.ILogger. 
  Got: Sitecore.ExperienceAnalytics.Core.Diagnostics.Logger. 
  XML: 
Description: An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error
and where it originated in the code.

The full stacktrace is as follows:

[ConfigurationException: Unexpected object type created from configuration node. Expected: Sitecore.ExperienceAnalytics.Core.Diagnostics.ILogger. Got: Sitecore.ExperienceAnalytics.Core.Diagnostics.Logger. XML: ]
 Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode) +604
 Sitecore.ExperienceAnalytics.Api.ApiContainer.GetUserAccessGuard() +21
 Sitecore.ExperienceAnalytics.Api.Http.Filters.DenyAnonymousUserFilterAttribute..ctor() +13
 System.RuntimeTypeHandle.CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor) +0
 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +2074
 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) +205
 System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type) +78
 System.Web.Http.Controllers.HttpControllerDescriptor..ctor(HttpConfiguration configuration, String controllerName, Type controllerType) +131
 System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache() +569
 System.Lazy`1.CreateValue() +708
 System.Lazy`1.LazyInitValue() +184
 System.Web.Http.Dispatcher.DefaultHttpControllerSelector.GetControllerMapping() +18
 System.Web.Http.Routing.AttributeRoutingMapper.AddRouteEntries(SubRouteCollection collector, HttpConfiguration configuration, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider) +76
 System.Web.Http.Routing.c__DisplayClass1_1.b__1() +75
 System.Web.Http.Routing.RouteCollectionRoute.EnsureInitialized(Func`1 initializer) +66
 System.Web.Http.Routing.c__DisplayClass1_0.b__0(HttpConfiguration config) +125
 Sitecore.Services.Infrastructure.Web.Http.ServicesConfigurator.Configure(HttpConfiguration config, RouteCollection routes) +762
 Sitecore.Services.Infrastructure.Sitecore.Pipelines.ServicesWebApiInitializer.Process(PipelineArgs args) +194
 (Object , Object ) +14
 Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +484
 Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
 Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
 Sitecore.Nexus.Web.HttpModule.Application_Start() +215
 Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +1184
 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +581
 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

[HttpException (0x80004005): Unexpected object type created from configuration node. Expected: Sitecore.ExperienceAnalytics.Core.Diagnostics.ILogger. Got: Sitecore.ExperienceAnalytics.Core.Diagnostics.Logger. XML: ]
 System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +714

The XML configuration line mentioned in the exception comes straight from the Sitecore 9.1 default config.

I inspected the Sitecore.ExperienceAnalytics dll with DotPeek, and I could find no reason why Sitecore.ExperienceAnalytics.Core.Diagnostics.Logger couldn't implement Sitecore.ExperienceAnalytics.Core.Diagnostics.ILogger.

Question

Why am I getting this exception? How can I remedy to that?

  • What does your <experienceAnalytics><api><logger> node look like in the configuration? – sitecorium Mar 20 at 8:45
  • It fails with the same error.If I Rebuild the entire Solution it works and I get what you would expect: <logger type="Sitecore.ExperienceAnalytics.Core.Diagnostics.Logger, Sitecore.ExperienceAnalytics.Core" singleInstance="true"/> but then on the website I get a weird error about an HTML Helper missing when instead it's there: 'System.Web.Mvc.HtmlHelper<dynamic>' does not contain a definition.... If I Build again - rather than Rebuild - I get the same error as before. – Emanuele Ciriachi Mar 20 at 10:43
  • Do you have any old 8.1 references in your project and hence DLLs hanging around in the bin folder? – sitecorium Mar 20 at 14:03
  • Could be an explanation. I will try removing all the references and only add 9.1 ones. I also have some libraries whose version exceed that of the vanilla 9.1 - HtmlAgilityPack, System.Web.Http.WebHost, Newtonsoft.Json, etc. Do you think that having newer versions could be an issue? – Emanuele Ciriachi Mar 20 at 17:32
0

The problem was a reference to the old Sitecore.ExperienceAnalytics.dll file, version 1.1.0.5295.

In version 9.1 this is split in several different files, but keeping a reference to the old one was causing the above mentioned issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.