Aspnetcore: System.Net.Http.Formatting.Extension 5.2.3 is not compatible with xamarinios10 (Xamarin.iOS,Version=v1.0). Package System.Net.Http.Formatting.Extension 5.2.3 supports: net (.NETFramework,Version=v0.0)

Created on 5 Apr 2018  路  12Comments  路  Source: dotnet/aspnetcore

I am working on a Xamarin.Forms PCL where I need to call a service for OCR(optical character recognition). The image captured by camera of the mobile device need to be passed to the service as byte stream. While calling the OCR service , MediaTypeFormatter under System.Net.Http.Formatting need to be passed.
I added nuget package for System.Net.Http.Formatting.Extension version 5.2.3.But when I am trying build the PCL project, getting this error System.Net.Http.Formatting.Extension 5.2.3 is not compatible with xamarinios10 (Xamarin.iOS,Version=v1.0). Package System.Net.Http.Formatting.Extension 5.2.3 supports: net (.NETFramework,Version=v0.0). I was previously able to perform same task in native Xamarin app for android without any issue. The problem seems to be with iOS.

My code is below :

```c#
var imageModel = new ImageModel();
imageModel.Image = filedata.DataArray;

        ///////////////////////////Call OCR Service////////////////////////////
        var client = new HttpClient();
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/bson"));
        MediaTypeFormatter bsonFormatter = new BsonMediaTypeFormatter();
        HttpResponseMessage response = await client.PostAsync<ImageModel>(eXfinity.SL.DigiCafe.OCRApp.Utility.OCRService, imageModel, bsonFormatter);
        var contents = "";
        if (response.IsSuccessStatusCode)
        {
            contents = await response.Content.ReadAsStringAsync();
        }

```

External

Most helpful comment

I got this issue sorted by replacing System.Net.Http.Formatting.Extension nugget with Microsoft.AspNet.WebApi.Client nuget

All 12 comments

@mkArtakMSFT / @dougbu - does this need to move to the AspNetWebStack repo?

@Eilon System.Net.Http.Formatting.Extension isn't part of the aspnet/AspNetWebStack repo. That package targets .NET 4.0 and hasn't been updated since 2015.

@pkpaul5 I suggest you contact the owners of the System.Net.Http.Formatting.Extension package.

@dougbu How can I contact owners of the System.Net.Http.Formatting.Extension package. This issue is also related to Xamarin.Please redirect me correct people.

@dougbu can you find out to which repo this issue should move and then move it there?

I can't find a GitHub repo related to this package. And the creators spoof Microsoft in the package metadata (<owners>Microsoft</owners>).

Suggest contacting the true owners using the "Contact owners" link on https://www.nuget.org/packages/System.Net.Http.Formatting.Extension/

Oh right it's not even a Microsoft package. I think we can close this issue here.

@pkpaul5 - it seems like you'll need to contact the package author directly via NuGet's contact link that @dougbu mentions or some other means.

@pkpaul5 thank you for your feedback. We're closing this issue as the behaviour discussed is external to any aspnet/* repo.

I got this issue sorted by replacing System.Net.Http.Formatting.Extension nugget with Microsoft.AspNet.WebApi.Client nuget

Sounds good, @pkpaul5 , glad you got it working!

I just fell into this trap. Absolutely terrible that by trying to use the HttpClient you can get here. Awful dev experience.

@pkpaul5 you solution worked for me, you saved my day, thank you!

I got this issue sorted by replacing System.Net.Http.Formatting.Extension nugget with Microsoft.AspNet.WebApi.Client nuget

Thanks your solution just saved my day!

Was this page helpful?
0 / 5 - 0 ratings