Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. #61445

Closed
ssarin3194 opened this issue Nov 11, 2021 · 6 comments
Labels
area-System.Diagnostics.Tracing needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration

Comments

@ssarin3194
Copy link

ssarin3194 commented Nov 11, 2021

Description

I have a .net framework app using 4.7.2 - It is a web application using MVC.

I do see this in the stack trace when I try to access the GET request in the controller of the web application.

[FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, 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)]
OpenTelemetry.Sdk..cctor() +0

Now, I am using

but it is expecting 5.0.1. Isn't it backward compatible?

Also, if I change this version to 5.0.1 --I see other package referencing failing in this case.

"C:\ASM-AlertingMicroService\src\ASMFeedback\ASMFeedback.csproj" (Restore target) (1) ->
(Restore target) ->
Feedback.csproj : error NU1605: Detected package downgrade: System.Diagnostics.DiagnosticSource from 6.0.0-rc.2.21480
.5 to 5.0.1. Reference the package directly from the project to select a different version.
Feedback.csproj : error NU1605: Microsoft.Asm.ASMFeedback -> Microsoft.Extensions.Logging 6.0.0-rc.2.21480.5 -> System
.Diagnostics.DiagnosticSource (>= 6.0.0-rc.2.21480.5)
Feedback.csproj : error NU1605: Microsoft.Asm.ASMFeedback -> System.Diagnostics.DiagnosticSource (>= 5.0.1)

Does this mean that the extensions.logging is dependant on this version 6.0.0..) which is why I am unable to restore the package?

Reproduction Steps

<PackageReference Include="Microsoft.Azure.Kusto.Cloud.Platform" />
<PackageReference Include="Microsoft.Azure.Kusto.Data" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
<PackageReference Include="Microsoft.Extensions.Options" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="Microsoft.Extensions.Primitives" />
<PackageReference Include="Microsoft.Identity.Client" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
<PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" />

<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="OpenTelemetry" />
<PackageReference Include="OpenTelemetry.Api" />
<PackageReference Include="OpenTelemetry.Exporter.Geneva" />

<Reference Include="System" />
<PackageReference Include="System.Buffers" />
<PackageReference Include="System.Collections.Immutable" />
<Reference Include="System.Data" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" />

<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.IO.Compression" />

<PackageReference Include="System.Memory" />
<Reference Include="System.Numerics" />    
<PackageReference Include="System.Numerics.Vectors" />
<Reference Include="System.Runtime.Caching" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />

<Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<PackageReference Include="System.Threading.Tasks.Extensions" />
<PackageReference Include="System.ValueTuple" />

<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />

<PackageReference Include="Microsoft.Web.Infrastructure" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />

<Reference Include="System.Web.Helpers" />
<Reference Include="System.Web.Mvc" />
<Reference Include="System.Web.Optimization" />
<Reference Include="System.Web.Razor" />
<Reference Include="System.Web.WebPages" />    
<Reference Include="System.Web.WebPages.Deployment" />
<Reference Include="System.Web.WebPages.Razor" />     

<PackageReference Include="WebGrease" />
<PackageReference Include="Antlr3.Runtime" />  

<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" />       

<PackageReference Include="bootstrap" />
<PackageReference Include="jQuery" />
<PackageReference Include="jQuery.Validation" />
<PackageReference Include="Microsoft.AspNet.Mvc" />
<PackageReference Include="Microsoft.AspNet.Razor" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization" />
<PackageReference Include="Microsoft.AspNet.WebPages" />    
<PackageReference Include="Modernizr" />        
<PackageReference Include="System.Reflection.Emit.Lightweight" />  
<PackageReference Include="MSBuild.Microsoft.VisualStudio.Web.targets" /> 

and my file where I specify these versions is

Expected behavior

Shouldn't be seeing this error irrespective of the version, especially since I am using a higher version)

Actual behavior

Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

[FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, 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)]
OpenTelemetry.Sdk..cctor() +0

[TypeInitializationException: The type initializer for 'OpenTelemetry.Sdk' threw an exception.]
OpenTelemetry.Sdk.get_SuppressInstrumentation() +0
OpenTelemetry.Logs.OpenTelemetryLoggerProvider..cctor() +15
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) +407
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) +274

Regression?

Yes, it worked in a .net framework build from the .csproj file that VS created. I now edited the .csproj file a bit to fit into my repo and use the common build settings as mentioned above and I am running to this error where the assembly is not getting loaded anymore.

Known Workarounds

No response

Configuration

dotnet --version
5.0.403
running on x64, using .net 4.7.2. This is run on Windows.

Other information

No response

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Nov 11, 2021
@ghost
Copy link

ghost commented Nov 11, 2021

Tagging subscribers to this area: @tarekgh, @tommcdon, @pjanotti
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

I have a .net framework app using 4.7.2 - It is a web application using MVC.

I do see this in the stack trace when I try to access the GET request in the controller of the web application.

[FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, 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)]
OpenTelemetry.Sdk..cctor() +0

Now, I am using

but it is expecting 5.0.1. Isn't it backward compatible?

Also, if I change this version to 5.0.1 --I see other package referencing failing in this case.

"C:\ASM-AlertingMicroService\src\ASMFeedback\ASMFeedback.csproj" (Restore target) (1) ->
(Restore target) ->
Feedback.csproj : error NU1605: Detected package downgrade: System.Diagnostics.DiagnosticSource from 6.0.0-rc.2.21480
.5 to 5.0.1. Reference the package directly from the project to select a different version.
Feedback.csproj : error NU1605: Microsoft.Asm.ASMFeedback -> Microsoft.Extensions.Logging 6.0.0-rc.2.21480.5 -> System
.Diagnostics.DiagnosticSource (>= 6.0.0-rc.2.21480.5)
Feedback.csproj : error NU1605: Microsoft.Asm.ASMFeedback -> System.Diagnostics.DiagnosticSource (>= 5.0.1)

Does this mean that the extensions.logging is dependant on this version 6.0.0..) which is why I am unable to restore the package?

Reproduction Steps

<PackageReference Include="Microsoft.Azure.Kusto.Cloud.Platform" />
<PackageReference Include="Microsoft.Azure.Kusto.Data" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Microsoft.Extensions.Configuration" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
<PackageReference Include="Microsoft.Extensions.Options" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
<PackageReference Include="Microsoft.Extensions.Primitives" />
<PackageReference Include="Microsoft.Identity.Client" />
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" />
<PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" />

<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="OpenTelemetry" />
<PackageReference Include="OpenTelemetry.Api" />
<PackageReference Include="OpenTelemetry.Exporter.Geneva" />

<Reference Include="System" />
<PackageReference Include="System.Buffers" />
<PackageReference Include="System.Collections.Immutable" />
<Reference Include="System.Data" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" />

<Reference Include="System.Drawing" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.IO.Compression" />

<PackageReference Include="System.Memory" />
<Reference Include="System.Numerics" />    
<PackageReference Include="System.Numerics.Vectors" />
<Reference Include="System.Runtime.Caching" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />

<Reference Include="System.Security" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<PackageReference Include="System.Threading.Tasks.Extensions" />
<PackageReference Include="System.ValueTuple" />

<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />

<PackageReference Include="Microsoft.Web.Infrastructure" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />

<Reference Include="System.Web.Helpers" />
<Reference Include="System.Web.Mvc" />
<Reference Include="System.Web.Optimization" />
<Reference Include="System.Web.Razor" />
<Reference Include="System.Web.WebPages" />    
<Reference Include="System.Web.WebPages.Deployment" />
<Reference Include="System.Web.WebPages.Razor" />     

<PackageReference Include="WebGrease" />
<PackageReference Include="Antlr3.Runtime" />  

<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" />       

<PackageReference Include="bootstrap" />
<PackageReference Include="jQuery" />
<PackageReference Include="jQuery.Validation" />
<PackageReference Include="Microsoft.AspNet.Mvc" />
<PackageReference Include="Microsoft.AspNet.Razor" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization" />
<PackageReference Include="Microsoft.AspNet.WebPages" />    
<PackageReference Include="Modernizr" />        
<PackageReference Include="System.Reflection.Emit.Lightweight" />  
<PackageReference Include="MSBuild.Microsoft.VisualStudio.Web.targets" /> 

and my file where I specify these versions is

Expected behavior

Shouldn't be seeing this error irrespective of the version, especially since I am using a higher version)

Actual behavior

Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

[FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.1, 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)]
OpenTelemetry.Sdk..cctor() +0

[TypeInitializationException: The type initializer for 'OpenTelemetry.Sdk' threw an exception.]
OpenTelemetry.Sdk.get_SuppressInstrumentation() +0
OpenTelemetry.Logs.OpenTelemetryLoggerProvider..cctor() +15
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context) +407
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) +274

Regression?

Yes, it worked in a .net framework build from the .csproj file that VS created. I now edited the .csproj file a bit to fit into my repo and use the common build settings and I am running to this error.

Known Workarounds

No response

Configuration

running on x64, using .net 4.7.2. This is run on Windows.

Other information

No response

Author: ssarin3194
Assignees: -
Labels:

area-System.Diagnostics.Tracing, untriaged

Milestone: -

@tarekgh
Copy link
Member

tarekgh commented Nov 11, 2021

@ssarin3194 thanks for your report. If you can provide a sample project demonstrating the issue, that would be helpful to investigate. Meanwhile, could you try to change the package reference in your project to reference version 6.0 of System.Diagnostics.DiagnosticSource?

	<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />

And in web.config file, please add the following binding redirect.

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

			<dependentAssembly>
				<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
				<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
			</dependentAssembly>
    ...

    </assemblyBinding>
  </runtime>

@tarekgh tarekgh added needs more info and removed untriaged New issue has not been triaged by the area owner labels Nov 11, 2021
@tarekgh
Copy link
Member

tarekgh commented Nov 11, 2021

CC @noahfalk @shirhatti

@ssarin3194
Copy link
Author

Hi,
I do have the web.config already with this change..

Also, when I update the package version to 6.0.0.0 i see the following error

"Feedback.csproj" (Restore target) (1) ->
(Restore target) ->
Feedback.csproj : error NU1605: Detected package downgrade: System.Runtime.CompilerServices.Unsafe from 6.0.0 to 6.0.0
-rc.2.21480.5. Reference the package directly from the project to select a different version.
Feedback.csproj : error NU1605: Microsoft.Asm.ASMFeedback -> System.Diagnostics.DiagnosticSource 6.0.0 -> System.Runtim
e.CompilerServices.Unsafe (>= 6.0.0)
Feedback.csproj : error NU1605: Microsoft.Asm.ASMFeedback -> System.Runtime.CompilerServices.Unsafe (>= 6.0.0-rc.2.2148
0.5)

Does this mean that I need to downgrade System.Runtime.CompilerServices.Unsafe also to 6.0.0?

@ghost ghost added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed needs more info labels Nov 11, 2021
@ssarin3194
Copy link
Author

The issue was that the dll version 5.0.0.1 was not getting loaded since we hadn't mentioned the binding in web.config. This had to be updated as --

Another solution was to ---

true needs to be set in the .csproj file which automatically takes care of redirects.

@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Diagnostics.Tracing needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration
Development

No branches or pull requests

3 participants