Could not load file or assembly 'System.Web.Http 4.0.0 after update from 2012 to 2013

前端 未结 28 1101
悲哀的现实
悲哀的现实 2020-11-28 01:09

I did the upgrade according to. http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

I get the er

相关标签:
28条回答
  • 2020-11-28 01:42
    <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
    </dependentAssembly>
    <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
    </dependentAssembly>
    
    0 讨论(0)
  • 2020-11-28 01:43

    When I installed Web Api 2.2 help this error started. I added this to the web.config and it solved my problem.

      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
    
    0 讨论(0)
  • 2020-11-28 01:44

    To resolve the Could not load file or assembly 'System.Web.Http' error use NuGet to install the Web API 2.1 WebHost.

    In solution explorer in the references right click and select manage nuget packages. (if not there install nuget)

    enter image description here

    In the manage NuGet Packages window on the left side click online then in top right search for Web Host and install Microsoft ASP.NET Web API 2.1 Web Host. (Once installed the install button will change to a green check)

    After that the project will reload and when it's build again the error will be resolved and the project will debug and run. The error will be gone and you may be 'The resource cannot be found. Just append the url ( ex from localhost:52088/ to localhost:52088api/products )

    Your question was good and helped me.

    Hope this answer helps!

    0 讨论(0)
  • 2020-11-28 01:45

    As others have said just reinstall the MVC package to your web project using nuget, but be sure to add the MVC package to any projects depending on the web project, such as unit tests. If you build each included project individually, you will see witch ones require the update.

    0 讨论(0)
  • 2020-11-28 01:46

    If you use several projects on a solution, and call method in one project to another project, make sure that all projects (called project and caller project) use the unique 'System.Net.Http' version.

    0 讨论(0)
  • 2020-11-28 01:47

    I fixed this by reinstalling the NuGet package, which corrects broken dependencies. From the package manager, run:

    Update-Package Microsoft.AspNet.WebApi -reinstall
    
    0 讨论(0)
提交回复
热议问题