4
votes

I am trying to upgrade my asp.net project from Mvc 4 to 5. I followed these instructions:

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

When I want to compile my project I am getting following error :

Could not load type 'System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter' from assembly 'System.Net.Http.Formatting, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

If I add the reference to System.Net.Http.Formatting Version=4.0.0.0 then I am getting this error:

Assembly 'System.Web.Http, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Net.Http.Formatting, Version=5.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

Can anyone help me?

1
As message says: include proper version. System.Web.Http references 5.2 and you reference 4.0Adriano Repetti
The hell with Microsoft shipping nugets and we are running into these update issues. No proper references to dlls are available in nuget eitherSaravanan

1 Answers

4
votes

I presume the unspoken part of your question (which @Adriano clearly did not infer) is that you don't see version 5.2.0.0 in the list when you go to add a reference, you see only version 4.0.0.0, right?

If so, the issue is probably your NuGet packages, which means you have an additional package you need to upgrade. In my case it was Microsoft.AspNet.WebApi.Client (apparently System.Net.Http.Formatting is in that assembly…?!?), which was upgraded in one of the projects in my solution but not the other. In your case, it looks like perhaps you need to install the upgrade of that particular package, and/or it was missed when you upgraded the other MVC packages.