-1

I am trying to install Application Insights on an Asp.Net MVC application by following this guide: Guide

I have tried both Automatic and Manual configurations, but each time I keep getting the same error when running my application.

Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I have uninstalled and tried to manually install the specific version of the DiagnosticSource file but it keeps installing 4.3.0 which is the next stable build. Also I have removed any bindings from Web.Config.

    === Pre-bind state information ===
LOG: DisplayName = System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
LOG: Appbase = file:///C:/projects/***/App.UI.Web/
LOG: Initial PrivatePath = *****\App.UI.Web\bin
Calling assembly : Microsoft.AspNet.TelemetryCorrelation, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\projects\***\App.UI.Web\web.config
LOG: Using host configuration file: C:\Users\***\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74ad50ed/1b8b2e6c/System.Diagnostics.DiagnosticSource.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/74ad50ed/1b8b2e6c/System.Diagnostics.DiagnosticSource/System.Diagnostics.DiagnosticSource.DLL.
LOG: Attempting download of new URL file:///C:/projects/**/App.UI.Web/bin/System.Diagnostics.DiagnosticSource.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

[FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule.Application_BeginRequest(Object sender, EventArgs e) +0
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +144
   System.Web.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0() +26
   System.Web.StepInvoker.Invoke(Action executionStep) +107
   System.Web.<>c__DisplayClass4_0.<Invoke>b__0() +23
   Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule.OnExecuteRequestStep(HttpContextBase context, Action step) +64
   System.Web.<>c__DisplayClass284_0.<OnExecuteRequestStep>b__0(Action nextStepAction) +56
   System.Web.StepInvoker.Invoke(Action executionStep) +91
   System.Web.<>c__DisplayClass4_0.<Invoke>b__0() +23
   Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule.OnExecuteRequestStep(HttpContextBase context, Action step) in /_/WEB/Src/Web/Web/ApplicationInsightsHttpModule.cs:164
   System.Web.<>c__DisplayClass284_0.<OnExecuteRequestStep>b__0(Action nextStepAction) +56
   System.Web.StepInvoker.Invoke(Action executionStep) +91
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +9956298
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +73
1
  • Downvoting because of no follow up Jul 30, 2021 at 7:19

1 Answer 1

0

Did you try to add the binding redirect for System.Diagnostics.DiagnosticSource to your Web.config? Something like:

<dependentAssembly>
    <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.0.4.0" />
</dependentAssembly>
2
  • What version of Application Insights did you install? Could you please provide the content of your Web.config, ApplicationInsights.config and packages.config files? May 21, 2021 at 5:10
  • BTW, remember to remove your instrumentation key before pasting the ApplicationInsishgts.config file's content here. May 21, 2021 at 5:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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