简体   繁体   English

升级ASP.Net WebAPI nuget包后出错

[英]Error after upgrading ASP.Net WebAPI nuget package

I have updated my WebApi nuget package from 5.2.2 to 5.2.3 and I started getting this error, 我已将WebApi nuget软件包从5.2.2更新到5.2.3,然后开始出现此错误,

The type 'System.Web.Http.ApiController' exists in both 'c:\\Program Files (x86)\\Microsoft ASP.NET\\ASP.NET MVC 4\\Assemblies\\System.Web.Http.dll' and '\\packages\\Microsoft.AspNet.WebApi.Core.5.2.3\\lib\\net45\\System.Web.Http.dll' 类型'System.Web.Http.ApiController'同时存在于'c:\\ Program Files(x86)\\ Microsoft ASP.NET \\ ASP.NET MVC 4 \\ Assemblies \\ System.Web.Http.dll'和'\\ packages \\ Microsoft.AspNet.WebApi.Core.5.2.3 \\ lib \\ net45 \\ System.Web.Http.dll'

I tried cleaning the solution/deleting reference and stuff but I could not get it working. 我尝试清理解决方案/删除参考资料和东西,但无法正常工作。 Please help. 请帮忙。

Update#: Reverting all the packages helped. 更新#:还原所有程序包都有帮助。 But still not sure if I missed something in the upgrade. 但是仍然不确定我是否在升级中错过了一些东西。

I got the same problem when getting Microsoft.AspNet.WebApi. 在获取Microsoft.AspNet.WebApi时,我遇到了同样的问题。

At Nuget Package Manager Console write this: 在Nuget软件包管理器控制台中,编写以下代码:

 Update-Package -ProjectName 'YourProjectNameGoesHere' -Reinstall

This will update all your packages and it will solve your problem.I hope it helps 这将更新您的所有软件包并解决您的问题。希望对您有所帮助

It happens sometimes with upgrades, another solution could be, close your solution and delete the content of packages folder of your solution , except repositories.config , uninstall the WebApi package and dependencies and install the newest version. 有时在升级时会发生这种情况,另一个解决方案可能是关闭解决方案并删除解决方案的packages文件夹中的内容( repositories.config除外),卸载WebApi软件包和依赖项并安装最新版本。 In some cases you need fix the assemblyBinding in web.config. 在某些情况下,您需要修复web.config中的assemblyBinding。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM