当我尝试运行解决方案时,我会收到错误: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版本4.0.0始终在使用中。我试图更新,降级,上帝知道现在几个小时。我没有尝试过任何工作。
这是我的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": {
}
}
在那里,我写了"System.Net.Http": "4.3.2"
,but as you can see in this image, the reference version is 4.0.0:
我做错了什么,我该如何解决?我有点困惑。我声明4.3.2,引用是4.0.0,错误说4.1.1?我到处搜索版本4.1.1,但没有找到任何东西。
编辑: 我在Windows 7机器上使用VS 2015。
我还尝试在config json文件中重定向到正确的程序集版本但没有成功。
答案 0 :(得分:1)
无论出于何种原因,如果使用多个软件包版本,VS 2015将回退到System.Net.Http
的v4.0.0。你能做的是:
答案 1 :(得分:0)
引用最新版本的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>
如果需要,请调整重定向中的版本和其他值。
至少它之前是如何工作的,可能是在.Net Core中发生了一些变化,在这种情况下,你至少知道现在要做什么。