An attempt by the HttpConfiguration..ctor (HttpRouteCollection) 'method to access the' HttpConfiguration.DefaultFormatters () 'method failed

I have a web API in which version 5.1.2 of the package is installed Microsoft.AspNet.WebApi.Client.

I am trying to access the API from an ASP.NET MVC application that also has the same version of the installed package.

However, in the Global.asax project of the Web API project, in the line below, I get the following exception:

WebApiConfig.Register(GlobalConfiguration.Configuration);

An attempt by the 'System.Web.Http.HttpConfiguration..ctor (System.Web.Http.HttpRouteCollection)' method to access the 'System.Web.Http.HttpConfiguration.DefaultFormatters ()' method failed.

+4
source share
4 answers

, , , .net.

, -API .net 4.5 unit test .net 4.5.3, , , nuget .net 4.5 , -API "HttpConfiguration..ctor(HttpRouteCollection)" " HttpConfiguration.DefaultFormatters()" ".

, .net -API - unit test, , .net framework 4.5.

+2

Microsoft.AspNet.WebApi.Client Microsoft.AspNet.WebApi.Core, .

+1

In my case, the problem was resolved when I installed Microsoft.AspNet.WebApi.Core. Thus, three libraries must be present and in harmony (remove / install) Microsoft.AspNet.WebApi.Client, Microsoft.AspNet.WebApi.CoreandNewtonsoft.json

+1
source

the same for the above answers in my case also works well after updating or reinstalling packages

Microsoft.AspNet.WebApi.Client
Microsoft.AspNet.WebApi.Core
0
source

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


All Articles