Reputation: 1175
I'm working on adding a new project to the existing solution in ASP.NET MVC. Everything goes fine until I update one of the packages. I found out that reference of "System.Net.Http" is pointing to a different location than I wanted to. This is how it looks like an object browser, I have 3 System.Net.Http Assemblies in different locations:
When I tried to reinstall the package via Nuget i got a message in Output console:
Found package 'System.Net.4.3.2' already exists in folder 'C:\MyProject\packages'
But when I looked in References of the project the path was to "C:\Program Files (x86)\Microsoft Visual...".
Could someone explain to me why this happens? Why Nuget is saying that he finds the package in a specific folder but adds a reference to another? Also how to make him add references from "packages" if he finds one there?
Upvotes: 1
Views: 1492
Reputation: 76720
Could someone explain to me why this happens? Why Nuget is saying that he finds the package in a specific folder but adds a reference to another? Also how to make him add references from "packages" if he finds one there?
That because .NET Framework
supports .NET Standard 2.0
starting from 4.6.1
,
those packages (
System.net
,System.Threading.Tasks.DataFlow
, etc) have anetstandard2.0
build. When anetstandard2.0
assembly is referenced in the desktop project, nuget team automatically add all the assemblies needed to make it work: no more package references. When nuget team add a newerSystem.Net.Http.dll
than what you were previously using, since that is part of netstandard2.0.
To resolve this issue, you could manually add binding redirect:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.1.1.1" />
</dependentAssembly>
</assemblyBinding>
You can check following threads for some more details:
System.Net.Http v4.2.0.0 being copied/loaded from MSBuild tooling
Issues with .NET Standard 2.0 with .NET Framework & NuGet
Hope this helps.
Upvotes: 2
Reputation: 122
It seems the DLL might have been added manually.
You should try to reinstall all yout NuGet :
Update-Package -reinstall -ProjectName <yourproject>
But make sure your solution is up-to-date and you have no change with against GIT/SVN version-control for it might change a lot of things.
Upvotes: 0