[.Net] Error loading ASP.NET application after installing New Relic agent

Agents question template

Please describe the behaviour you are seeing, and how that differs from what you expect.

Please provide information on your environment, and any further information you believe is relevant, such as the below:

  • APM Agent Language
    .NET

  • APM Agent Version
    8.37.0.0

  • Operating System
    Windows Server 2019 (and 2012 R2)

  • Frameworks your app is using
    ASP .NET (Framework 4.6)

Issues Found

Error - DotNetCore/Env/Versions
Error determining the version .NET Core installed.

Warning - DotNet/Profiler/EnvVarKey
Some environment variables needed for system wide/non-IIS .NET application profiling are not set. If you are attempting to instrument a non-IIS .NET framework application, re-run the .NET agent installer and select the “Instrument all .NET framework applications” option on the “Custom Setup” screen.

Warning - DotNet/Env/TargetVersion
Unable to find app config file. Are you running the Diagnostics CLI from your application’s parent directory?

Failure - DotNet/Requirements/RequirementCheck
Detected failed DotNet Agent requirement checks. Failed checks:
DotNet/Requirements/NetTargetAgentVersionValidate


After creating a new server instance with IIS and IIS-ASPNET45 installed, my application landing page loads fine. However, after I install the new relic agent and restart IIS, I get the following error

An attempt to override an existing mapping was detected for type NewRelic.Agent.Core.Attributes.IAttributeValue with name “”, currently mapped to type NewRelic.Agent.Core.Segments.AttributeValue, to type NewRelic.Agent.Core.Attributes.AttributeValue.

I did some additional research. I’d previously been successfully running newrelic-agent-win-x64-8.25.214.0 so I installed that version of the agent again, and this error no longer occurs.

I upgraded the agent one version at a time and it worked for 8.26.630 and 8.27.139.0, but shows this error on 8.28.0.0 and above. I did not see any upgrade notes on https://docs.newrelic.com/docs/release-notes/agent-release-notes/net-release-notes/net-agent-8280

2 Likes

Hello @kwarner,

Welcome to our forum! Thank you for your post, and the additional testing and information. Do you know if you are using Unity Dependency Injection?

It would also be useful to know what your app does. Can you tell me more about it? What does it do? Is it a webjob? Web API? MVC?

Can you copy and paste the entire error trace into your response? I will be partnering with our engineering team to see what changes were made between v8.27 and v8.28 that would cause that error once I can examine the full stack trace. Thank you!

Hi Kwarner, I’ve just tried to upgrade from 8.20 to 8.36 and I find an identical error. At this point I’ve rolled back to 8.23.107 but I will also try 8.27.139 based on your results. I’m already working with support for both my web product (they just pointed me to your post) and New Relic, I’m posting this, hoping the issue might be easier to identify/resolve with more info. Here is the full error I get in my browser UI immediately after restarting IIS after installing agent 8.36.

Server Error in ‘/’ Application.
An attempt to override an existing mapping was detected for type NewRelic.Agent.Core.Attributes.IAttributeValue with name “”, currently mapped to type NewRelic.Agent.Core.Segments.AttributeValue, to type NewRelic.Agent.Core.Attributes.AttributeValue.
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.

Exception Details: Unity.RegistrationByConvention.Exceptions.DuplicateTypeMappingException: An attempt to override an existing mapping was detected for type NewRelic.Agent.Core.Attributes.IAttributeValue with name “”, currently mapped to type NewRelic.Agent.Core.Segments.AttributeValue, to type NewRelic.Agent.Core.Attributes.AttributeValue.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[DuplicateTypeMappingException: An attempt to override an existing mapping was detected for type NewRelic.Agent.Core.Attributes.IAttributeValue with name “”, currently mapped to type NewRelic.Agent.Core.Segments.AttributeValue, to type NewRelic.Agent.Core.Attributes.AttributeValue.]
Unity.RegistrationByConvention.RegistrationByConventionExtensions.RegisterTypes(IUnityContainer unityContainer, IEnumerable1 types, Func2 getFromTypes, Func2 getName, Func2 getLifetimeManager, Func2 getInjectionMembers, Boolean overwriteExistingMappings) +1530 Carekey.Web.UI.WebApiDependencyInjectionConfig.RegisterTypes(IUnityContainer container) +183 Carekey.Web.UI.<>c.<.cctor>b__10_0() +39 System.Lazy1.CreateValue() +727
System.Lazy`1.LazyInitValue() +436
Carekey.Web.UI.WebApiDependencyInjectionConfig.Register(HttpConfiguration config) +47

[HttpException (0x80004005): An attempt to override an existing mapping was detected for type NewRelic.Agent.Core.Attributes.IAttributeValue with name “”, currently mapped to type NewRelic.Agent.Core.Segments.AttributeValue, to type NewRelic.Agent.Core.Attributes.AttributeValue.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +467
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +185
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) +264

[HttpException (0x80004005): An attempt to override an existing mapping was detected for type NewRelic.Agent.Core.Attributes.IAttributeValue with name “”, currently mapped to type NewRelic.Agent.Core.Segments.AttributeValue, to type NewRelic.Agent.Core.Attributes.AttributeValue.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +493
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4261.0

Yes, we use Unity. It’s a MVC and Web API project (5.2.3)

Hi @kwarner, could you paste the entire error trace for us as well so we can look into this issue further?