将Microsoft.Aspnet.Webapi.Webhost软件包安装到我的web api项目后,我最终会遇到以下异常:
Could not load file or assembly ‘System.Web.Http,Version=5.0.0.0,
Culture=neutral,PublicKeyToken=31bf3856ad364e35’ or one of its
dependencies. The located assembly’s manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
解决方法
我通过重新安装NuGet软件包来解决这个问题,这纠正了破坏的依赖关系.从包管理器运行Update-Package Microsoft.AspNet.WebApi -reinstall.