Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:Upgrade MVC4 to MVC5 in VS2012

I am getting below error after upgrade my project from MVC4 to MVC5. I followed How to Upgrade an ASP.NET MVC 4 and Web API Project to ASP.NET MVC 5 and Web API 2

Assembly 'WebServices.WebApi.External, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' How to solve this issue?

like image 817
James123 Avatar asked Oct 21 '13 19:10

James123


People also ask

What is difference between MVC4 and MVC5?

Identity feature in mvc4 is not available where as this is available in mvc5. 2. Authentication filter is not available in MVC4 where as Authentication filter is available in MVC5. Authentication filter is a new kind of filter in ASP.NET that runs prior to the authentication in MVC.

What is MVC5?

ASP.NET MVC 5 is a web framework based on Model-View-Controller (MVC) architecture. Developers can build dynamic web applications using ASP.NET MVC framework that enables a clean separation of concerns, fast development, and TDD friendly.

Is ASP.NET MVC 5 outdated?

Is the framework outdated? ASP.NET MVC is no longer in active development.


3 Answers

I also follow that article without full success at start but

To fix this "simple" create new web mvc project and save it then open web.config, web.config from views, packages.config, and .csproj in notepad

then open your project and look at difference in entry for version numbers of files e.g. in packages you should see

<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />

but you can have

<package id="Microsoft.AspNet.Mvc" version="4.x.x.x" targetFramework="net40" />

in web.config

<dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>

but you can have

<dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>

in .csproj

<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <Private>True</Private>
      <HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.Helpers.dll</HintPath>
    </Reference>

but you can have

<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <Private>True</Private>
      <HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll</HintPath>
    </Reference>

replace all with newer values

after that do Ctrl+Shift+B and in nuget console update all packages by comand Update-Package

for me this work finally

like image 29
Livius Avatar answered Oct 02 '22 08:10

Livius


I solved this by installing the System.Web.Http.WebHost. You can install by using nuget and search for WebHost. This is the exact link https://www.nuget.org/packages/Microsoft.AspNet.WebApi.WebHost/5.1.0

you can also install it from the Package Manager Console: PM> Install-Package Microsoft.AspNet.WebApi.WebHost

like image 37
Tyrone Moodley Avatar answered Oct 02 '22 07:10

Tyrone Moodley


I had a similar problem, it was due to me using the

_bin_deployableAssemblies

This folder had the System.Web.Http in it at version 4. I deleted this folder and it worked

like image 148
Tanzy Avatar answered Oct 02 '22 09:10

Tanzy