[英]Dependency Mismatch: Solution won't use anything newer than 4.0.0.0
When I try to run the solution, I'll get an error: Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
当我尝试运行解决方案时,会出现错误:
Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
System.Net.Http version 4.0.0 is always in use. 始终使用System.Net.Http版本4.0.0。 I have tried to update, downgrade and god knows what for hours now.
我试图进行更新,降级,而上帝已经知道了几个小时了。 Nothing I've tried works.
我没有尝试过任何工作。
This is my project.json: 这是我的project.json:
{
"dependencies": {
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.Kestrel": "1.1.2",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.2",
"Microsoft.Extensions.Configuration.FileExtensions": "1.1.2",
"Microsoft.Extensions.Configuration.Json": "1.1.2",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.2",
"Microsoft.Extensions.Logging": "1.1.2",
"Microsoft.Extensions.Logging.Console": "1.1.2",
"Microsoft.Extensions.Logging.Debug": "1.1.2",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.2",
"Microsoft.ServiceFabric": "5.6.220",
"Microsoft.ServiceFabric.AspNetCore.WebListener": "2.6.220",
"Microsoft.ServiceFabric.Data": "2.6.220",
"Microsoft.ServiceFabric.Services": "2.6.220",
"Microsoft.AspNetCore.Mvc.Formatters.Xml": "1.0.1",
"Microsoft.AspNetCore.Authentication.Cookies": "1.1.1",
"microsoft.aspnetcore.authentication.jwtbearer": "1.1.1",
"System.Net.Http": "4.3.2"
},
"tools": {
},
"frameworks": {
"net461": {}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},
"scripts": {
}
}
In there I have written "System.Net.Http": "4.3.2"
, but as you can see in this image, the reference version is 4.0.0: 在这里,我编写了
"System.Net.Http": "4.3.2"
, 但是正如您在此图中看到的,参考版本是4.0.0:
What am I doing wrong and how can I fix it? 我在做什么错,我该如何解决? I'm getting a bit confused.
我有点困惑。 I declare 4.3.2, the reference is 4.0.0 and the error says 4.1.1?
我声明4.3.2,引用为4.0.0,错误为4.1.1? I have searched everywhere for version 4.1.1, but didn't find anything.
我到处都搜索了4.1.1版,但没有找到任何东西。
Edit: I'm using VS 2015 on a windows 7 machine. 编辑:我在Windows 7计算机上使用VS 2015。
I have also tried to redirect to the correct assembly version in the config json file with no success. 我也尝试过重定向到config json文件中的正确程序集版本,但没有成功。
For whatever reason VS 2015 would fallback to v4.0.0 of System.Net.Http
if multiple package versions were used. 无论出于何种原因,如果使用多个软件包版本,VS 2015都将回退到
System.Net.Http
v4.0.0。 What you could do is: 您可以做的是:
.NET Core
projects to v1.1 and use VS 2017. .NET Core
项目升级到v1.1并使用VS 2017。 Microsoft.AspNetCore.Authentication.JwtBearer
which has a dependency on System.Net.Http
v4.0.0. Microsoft.AspNetCore.Authentication.JwtBearer
这对依赖System.Net.Http
V4.0.0。 If Microsoft.AspNetCore.Authentication.JwtBearer
is needed in your project, then #1 might be the only option. 如果您的项目中需要
Microsoft.AspNetCore.Authentication.JwtBearer
,则#1可能是唯一的选择。
Reference the latest version of System.Net.Http and add to your app.config bindingRedirect like that: 引用最新版本的System.Net.Http并添加到您的app.config bindingRedirect中,如下所示:
<runtime>
<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.1.0.0" newVersion="4.1.1.0" />
</dependentAssembly>
<!-- Other possible redirects... -->
</assemblyBinding>
</runtime>
Please adjust the version and other values in my redirect if needed. 如果需要,请在重定向中调整版本和其他值。
At least that's how it worked before, may be in .Net Core something changed, in that case, you at least have an idea of what to do now. 至少以前是这样的,在.Net Core中可能有所更改,在这种情况下,您至少对现在应该做什么有一个了解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.