assembly uses System.Web.Http 5.1 which has a higher version than referenced assembly System.Web.Http 5.0
Asked Answered
N

4

14

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...

Numeral answered 13/4, 2014 at 13:55 Comment(0)
N
19

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

Numeral answered 13/4, 2014 at 15:38 Comment(2)
This does help at the end, but I had to struggle with other problems after the upgrade first, as always, sadly.Incongruent
I think you can be more precise if you specify the package Id "Microsoft.AspNet.WebApi"Georg
G
2

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.

Gardiner answered 21/5, 2014 at 7:54 Comment(0)
M
1

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.

Misdeed answered 13/11, 2014 at 13:43 Comment(0)
U
0

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.

Urgency answered 18/5, 2018 at 0:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.