类型' ApiController'存在于' System.Web.Http,Version = 4.0.0.0'和' System.Web.Http,Version = 5.2.3.0'

时间:2017-05-24 01:14:15

标签: c# asp.net asp.net-mvc

我尝试升级我的NuGet包以获得更新版本的asp.net程序集(5.2.3)。升级后我在编译时遇到此错误。

我已经清除了包文件夹并重建了,我已经重新安装了所有包,我已经清除了我的垃圾箱等。升级到5.2.3之后我无法构建因为我不断收到此错误。我的bin中的System.Web.Http.dll版本是正确的版本。这个dll不在我的GAC中。我不知道编译器还在哪里找到这个dll的4.0.0.0版本。我的web.config中有一个bindingRedirect。

<dependentAssembly>
    <assemblyIdentity name="System.Web.Http" culture="neutral" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>

我也跑了Update-Package -ProjectName [ProjectName] -Reinstall

1 个答案:

答案 0 :(得分:0)

我终于找到了问题的根源。 .csproj文件仍然引用旧的DLL,即使在浏览VS解决方案资源管理器中的引用时,它只存在一次,并且版本正确。我从.csproj文件中删除了那些旧的引用,现在解决了这个错误。