简体   繁体   中英

The type 'ApiController' exists in both 'System.Web.Http, Version=4.0.0.0' and 'System.Web.Http, Version=5.2.3.0'

I tried upgrading my NuGet packages to get newer versions of asp.net assemblies (5.2.3). After upgrading them I get this error upon compiling.

I have cleared packages folder and rebuilt, I have reinstalled all packages, I have cleared my bin, etc. After upgrading to 5.2.3 I cannot build because I keep getting this error. The version of the System.Web.Http.dll in my bin is the correct version. This dll is not in my GAC. I'm not sure where else the compiler is finding version 4.0.0.0 of this dll. I have a bindingRedirect in my web.config.

<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>

I also ran Update-Package -ProjectName [ProjectName] -Reinstall

I finally got to the root of my issue. The .csproj file was still referencing the older DLL, even though when browsing the references in VS solution explorer it was only in there once, and the correct version. I deleted those older references from the .csproj file and now resolved this error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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