Question

I created a new Project in Visual Studio 2013, a WebApi & MVC 5 project and updated all nuget packages. It updated to mvc 5.1. Now I cannot Successfully build the project it says

assembly uses System.Web.Http 5.1.0.0 which has a higher version than referenced assembly System.Web.Http 5.0.0.0

Anyone run into this before? Why these kind of problems do occur so often in Visual Studio? Does anybody know how to solve this because I really am trying hard but no luck so far...

Was it helpful?

Solution

Solved

I opened the Package Manager Console in Visual Studio and run the command

PM> Update-package

It magically resolved everything for me. You can find Package Manager Console under

  1. Tools
  2. Nuget Package Manager
  3. Package Manager Console

This command deletes all the old packages under the package folder and updates everything if necessary, you may also run the command on a specific package. Here all the variants of the command http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference#Update-Package

Let me know if you found this useful I'm curious to know if it just happened to me accidentally

OTHER TIPS

A new version of ASP.NET was released. Announcement here : http://blogs.msdn.com/b/webdev/archive/2014/01/20/announcing-the-release-of-asp-net-mvc-5-1-asp-net-web-api-2-1-and-asp-net-web-pages-3-1.aspx

You probably have two projects in your solution, where project A references project B. Both projects reference ASP.NET, but there is a version mismatch.

I had a very similar problem to yours exactly with a reference to System.Web.Http and have documented it here:

Could not load assembly error

When you update a Nuget package it would update dependent packages. But it would not update other packages in your solution that depend on the updated packages. These other packages might not even have a newer version built with the udpated packages.

So the solution is either to udpate all your packages like you did (this might not always work) or add binding redirects to the latest version of your assembly reference to your application config.

I solved this way. As I currently have fwk 4.0.0.0 and don't want to install 5.X:

  1. I removed the referenced DLLs
  2. I removed a couple of bindingRedirects at packages.config,
  3. Then I rebuilded that solution, that throws me errors
  4. Then I added the reference again

And voilà, the solution is running with the fwk that I have.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top