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

前端 未结 28 1098
悲哀的现实
悲哀的现实 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:33

    Or you could do this from NuGet Package Manager Console

     Install-Package Microsoft.AspNet.WebApi -Version 5.0.0
    

    And then you will be able to add the reference to System.Web.Http.WebHost 5.0

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

    I had same problem and reinstalling package doesn't work.

    My application runs in LocalIIS(not IIS EXPRESS). I enable Assembly Load Trace and find out it want load System.Web.Http load from below temp catche. so remove all catch folders in it.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files[my application]

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

    I could solve similar problem with System.Net.HTTP by adding assembly reference in app.config of main application.

      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.1.1.1" newVersion="4.0.0.0" />
          </dependentAssembly></runtime>
    
    0 讨论(0)
  • 2020-11-28 01:35

    I simply set Copy Local = true on the missing assembly and that worked. This of course happens by right clicking on the missing reference (which is stated in the error message) and selecting properties; as below:

    This should then solve one problem as there might be more than one assembly causing the issue - what I did is I selected all assemblies and right click on them; selected properties; and set them all to Copy Local = true; and then republish.

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

    YES!!!

    Install-Package Microsoft.AspNet.WebApi -Version 5.0.0
    

    It works fine in my case....thnkz

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

    I got this issue when deploying to Azure using the Publish feature. Remember to clear files at destination.

    Publish Settings -> File Publish Options drop down -> Check Remove additional files at destination

    This solved my issue, in case people have to hunt around for this like I did. Everything was the same version in my project/solution, just not at the destination I was deploying to.

    0 讨论(0)
提交回复
热议问题