C# Can';t更新至Web API 2.1
我正在尝试将我的Web API从2.0更新到2.1,但出现以下错误 无法加载文件或程序集“System.Web.Http,Version=5.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集清单定义与程序集引用不匹配。(来自HRESULT的异常:0x8013100) 在这条线上C# Can';t更新至Web API 2.1,c#,asp.net-web-api,C#,Asp.net Web Api,我正在尝试将我的Web API从2.0更新到2.1,但出现以下错误 无法加载文件或程序集“System.Web.Http,Version=5.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集清单定义与程序集引用不匹配。(来自HRESULT的异常:0x8013100) 在这条线上 GlobalConfiguration.Configure(WebApiConfig.Register) 更新后运行API时,在gl
GlobalConfiguration.Configure(WebApiConfig.Register)代码>
更新后运行API时,在global.asax.cs
中
但这是正常的,因为它在csprog中引用了5.1.0
<Reference Include="System.Web.Http, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
我也有同样的问题,但有时它会给我一个错误,说一些插件依赖于Microsoft.AspNet.WebApi.core 5.0.0。
但是我不明白为什么,因为插件的依赖项是Microsoft.AspNet.WebApi.core>=5.0.0。
因此,5.1.0应该是可行的
我试图更新并忽略与的依赖项
Install-Package -Ignoredependencies Microsoft.AspNet.WebApi -Version 5.1.0
我不再有错误了,但是API返回错误500
你知道为什么Web API 2.1的更新不起作用吗?你有程序集绑定重定向吗
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
它现在可以工作了!包管理器控制台是否应该添加此项?谢谢是的,安装powershell脚本应该添加或更新此内容。也许内部某个地方发生了错误?试着在一个空项目中复制它,如果是的话,欢迎在项目的github上发布bug报告。
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>