10

Now I read the book "ASP.NET MVC 5, Freeman", and I've created 3 projects:

  • SportsStore.Domain - for logic
  • SportsStore.UnitTests - for tests
  • SportsStore.WebUI - for views and controllers

Using NuGet command line I have install a lot of packages, like in the book:

Instal-Package Microsoft.Aspnet.Mvc -version 5.0.0.0 -projectname SportsStore.Domain .. etc ..

But I think that I have install something wrong, because now I have error:

Build "SportsStore.WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" use "System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" of the later version than the assembly "System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", to which reference is made c:\Users\Дима\Documents\Visual Studio 2013\Projects\SportsStore\SportsStore.WebUI\bin\SportsStore.WebUI.dll SportsStore.UnitTests

Can't understand, how to solve it

3
  • 3
    uninstall the MVC pakcage from the Domain package, and this time install it with the version tag being 5.2.2.0 (-version 5.2.2.0) Commented Jan 8, 2015 at 14:33
  • I added an answer - I would appreciate it if you marked it as correct if it solved your problem Commented Jan 8, 2015 at 14:49
  • 1
    Had same issue with same lab from this book. Resolved by uninstalling Microsoft.Aspnet.Mvc for UnitTests project and reinstall with 5.2.2.0 version key Commented Aug 20, 2015 at 9:12

7 Answers 7

12

I ran into this exact same problem myself and decided to update the versions of Microsoft.Aspnet.Mvc to the same version defined in the WebUI project. It did the trick for me and I thought I would share.

So in Package Manager Console, I ran:

Update-Package Microsoft.Aspnet.Mvc -version 5.2.3 -projectname SportsStore.Domain
Update-Package Microsoft.Aspnet.Mvc -version 5.2.3 -projectname SportsStore.UnitTests

Note: My version at the time of this writing was 5.2.3 . You state above that yours was 5.2.2, so use that instead.

Sign up to request clarification or add additional context in comments.

1 Comment

In my case, different projects were referring to different versions. I had to update all the projects to use the same version. Thanks.
10

The error message in the build explains the problem in clear terms if you know how to read it.

It starts by telling you that the WebUI project uses 5.2.2.0:

SportsStore.WebUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null use System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Then it tells you that one of your projects is referencing a different version:

later version than the assembly System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Since you stated in your question that you installed 5.0.0.0 in your domain project, you will need to remove that version from the project, and install the correct version (in this case 5.2.2.0)

1 Comment

In my case, this is because I used Nuget to download MVC5 in my main project, however the Tests project was scaffolded with the default MVC4. I simply added to the Trsts project a reference to the MVC5 DLLs in the core project.
3

You have to update your Microsoft Asp.NET MVC version. To do that;

  1. Click Tool and select "NuGet Package Manager"
  2. Select "Manage NuGet Package Manager Console"
  3. Search for Microsoft Asp.NET MVC and update it.
  4. Restart Visual Studio

Comments

1

You may also try to replace the corresponding section by this section in web.config. Not sure if it will work but it will only take 2 minutes to try.

<dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.2.2.0" />
      </dependentAssembly>

Comments

1

Normally when you upgrade/ install/ uninstall MVC package it depends on any other library for example I had issue that it was depending on MvcSiteMapProvider which was not compatible with MVC Version 5.2.7.

Here is solution for these type of issues

  1. Uninstall dependency library (for example in my case I uninstall MvcSiteMapProvide)
  2. Upgrade MVC version either use NuGet Package

  3. Manager or console. Install again uninstall library ( In my case I install again MvcSiteMapProvider)

Delete Obj folder, Clean and Build project.

Comments

0

I had this problem with the same project and to solve it is very easy, just click on Build►Clean Solution, this will erase some files in the bin folder and after that just rebuild your solution. this actually fixed my problem.

Comments

-1

Go to Prerences find System.Web.Mvc then remove it

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.