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

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

    I solved this problem by reverting the changes that nuget had made to my web.config after running nuget. Revert the changes to a previous working version.

      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" 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:55

    This might help someone.

    I decided to go with MVC4 app.

    run project, worked

    Then Installed few packages like,
    Microsoft ASP.NET WEB API 2.2 (4 packages)
    Microsoft ASP.NET WEB API 2.2 Help Page
    Microsoft ASP.NET WEB API 2.2 OWIN

    run project, same error as mentioned in question

    Solution:

    In web.config

     <dependentAssembly>
          <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.2.3.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.2.3.0" />
     </dependentAssembly>
    


    Problem Solved


    but then, some hotfix error found, To resolve it, go to VIEW folder of your MVC4 project, find second web.config file and changed version from 2.0.0.0 to 3.0.0.0 as shown below.


    <configSections>
        <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
          <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
        </sectionGroup>
      </configSections>
    

    0 讨论(0)
  • 2020-11-28 01:59
     Installing NuGet package ASP.NET.MVC solved the issue for me. 
     To install package.
     - Right click on project 
     - Select "Manage NuGet Packages"
     - Select Online->Nuget.org from left menu
     - select "Microsoft ASP.NET MVC"
     - Click Install
    
     If you have already installed package earlier, please update the package by selecting Updates from left menu and then selecting "Microsoft ASP.NET" and click Update.
    

    0 讨论(0)
  • 2020-11-28 02:00

    I found the solution ! Delete folder named package in project directory and then rebuild to run it.

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