System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter Error

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 get the following error:

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

If I add a link to System.Net.Http.Formatting Version=4.0.0.0 , I get 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 more higher version than the reference assembly 'System.Net.Http.Formatting, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35'

Can anybody help me?

+4
source share
1 answer

I assume that the unspoken part of your question (that @Adriano clearly did not conclude) is that you do not see version 5.2.0.0 in the list, when you go to add a link, you only see version 4.0.0.0, right?

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

+4
source

Source: https://habr.com/ru/post/978007/


All Articles