Take a package like Microsoft.AspNetCore.Http.Abstractions, it depends on Microsoft.AspNetCore.Http.Features by this line in its nuspec:
<dependency id="Microsoft.AspNetCore.Http.Features" version="2.1.1" exclude="Build,Analyzers" />
with the 2.1.1 meaning >= 2.1.1, in NuGet parlance.
So I take a dependency on Microsoft.AspNetCore.Http.Abstractions, version 2.1.1 exactly in my project.
Currently, there is both a version 2.1.1 and 2.2 of Microsoft.AspNetCore.Http.Features in NuGet, so my project ends up with Microsoft.AspNetCore.Http 2.1.1 and Microsoft.AspNetCore.Http.Features 2.2.
But then, I run my project and I get assembly binding errors, because the actual Microsoft.AspNetCore.Http.Abstractions 2.1.1 DLL depends on Microsoft.AspNetCore.Http.Features 2.1.1.
Summary: Nuspec says >= 2.1.1, DLL is bound to == 2.1.1.
This seems to be true for almost all MS packages.
Is this a monumental cock-up, or am I doing something wrong? I'm having to traverse the dependency graphs myself and lock myself to each exact version which each DLL needs, because the nuspecs don't appear to be properly configured.
What's going on?
Example binding error:
Unable to load one or more types: Could not load file or assembly 'Microsoft.AspNetCore.Http.Features, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
(because I've been given 2.2 by NuGet).
Related
After upgrading the FluentValidation NuGet package in my WPF application from version 11.0.2 to 11.4.0, I began to receive the following error when attempting to execute my test suite:
System.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.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)
Source=FluentValidation
My NuGet packages folder contains the system.threading.tasks.extensions package for versions 4.4.2 and 4.5.4, but not 4.2.0.0.
I am not sure why I am getting this error, or how to resolve it.
I have reviewed the answers to questions by others having similar problems, but without finding a solution.
Our Visual studio project is a 64-bit website which requires the crystal reports runtime installed. We would like to include nuget packages to avoid installing the runtime.
I installed the CrystalReports.Engine nuget and 16 nuget/references are also applied including log4net v1.2.10. The project files reference "Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821". This is a pretty old version of the log4net.
When I run our website and try to generate a report, I get the exception "Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040...". It appears that the libraries are looking for the 32-bit version of log4net.
The nuget packages include 13.0.30.3805, not the latest 13.0.32 libraries. After doing some searching on-line, I am concerned that these nugets are not SAP generated nugets.
This leads me to a few questions:
Are these SAP Crystal Reports nugets?
How do they distinguish between 32-bit and 64-bit projects?
Why are these nugets not using the latest version of the libraries.
How do I resolve this error? (everything I have tried, doesn't fix the problem)
I created a .NET Full Framework class library using EF Core v 2.2.1 and downloaded the EF Core driver v 2.x for Linqpad 5 (5.36.03), and when I try to create a new connection to the class library DLL, I get the following error message:
Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependenceis. The system cannot find the file specified.
I have clicked the 'Restore nuGet Dependencies' and it gives me the message 'No NuGet dependencies detected'.
Any thoughts?
Did exactly what #magicandre1981 suggested and targted 4.7.2 for my class library. That fixed it!
When using autofac with snap, I encounter the following exception:
Test method Halcyon.Mall.Logging.LogCallTests.FooLogCallInterceptor_ShouldBeCalled threw exception:
Autofac.Core.DependencyResolutionException: An exception was thrown while executing a resolve operation. See the InnerException for details. ---> System.IO.FileLoadException: Could not load file or assembly 'Fasterflect, Version=2.0.1.0, Culture=neutral, PublicKeyToken=a64e1179c81b1e25' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The autofac (2.5.2.830) is installed as a nuget package manually.
The fasterflect (2.0.4429.39723) is installed automatically as a dependent package of SNAP (1.7.3)
I had the same problem today with Snap 1.7.7 -- the latest version. Snap.StructureMap appears to require Fasterflect 2.0 but a NuGet of Snap 1.7.7 retrieves the latest Fasterflect, which is 2.1. I was able to solve it by downloading Fasterflect 2.0.2 using NuGet in a separate project (PM> Install-Package Fasterflect -version 2.0.2), then deleting the existing reference to Fasterflect from my main project, then browsing to and adding a file-based reference to the older Fasterflect 2.0.2 DLL.
I have created a nuget package for a library we use at my company. The library uses both Fluent NHibernate 1.3.0.717 and Structure Map 2.6.2.
Because some folks are using StructureMap 2.6.3, I created the dependencies of the package as:
<dependencies>
<dependency id="FluentNHibernate" version="[1.3,)" />
<dependency id="structuremap" version="[2.6.2,)" />
</dependencies>
And when the package shows up in NuGet it says that Structure Map >=2.6.2 is required. So far, so good.
Here's the issue:
When I go to add this library to my project, it always installs Structure Map 2.6.3. It even uninstalls 2.6.2 from my project in order to do so.
I don't see any sign that structure map 2.6.3 is a dependency of FluentNHibernate (or any of its dependencies) so I am absolutely baffled as to why it will not simply add my library with the FluentNHibernate dependencies and leave my StructureMap 2.6.2 alone.
I don't know if this would have anything to do with it, but we host the packages on a UNC share.
Read David Ebbo's blog series on NuGet Versioning and dependency resolution.
In short, we always pick the dependency with the lowest major and minor and highest build and revision number (based on the dependency's constraints). This is so that you automatically get bugs fixes (non breaking) when using a package as a dependency.