How to resolve HttpClient exists in multiple libs

Viewed 6414

I'm trying to use the IdentityModel package in a .NET Core class library but I get a conflict between netstandard and System.Net.Http:

error CS0433: The type 'HttpClient' exists in both
'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and
'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

The project file:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="IdentityModel" Version="2.8.1" />
  </ItemGroup>
</Project>

The default Class1.cs:

using System;
using System.Net.Http;
namespace Test
{
    public class Class1
    {
        HttpClient client = new HttpClient();
        public Class1() {}
    }
}

What's the right way to resolve this issue?

2 Answers
Related