0

I was using IntrospectionClient and TokenClient from the IdentityModel v3.6.1.
But when I upgraded the project from .Net 4.7.1 to 4.7.2 I got build errors:

"Error CS0012 The type 'HttpMessageHandler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

The project is already referencing "System.Net.Http" v4.3.3

Does anyone have an idea wat has changed and what I can do to solve this problem?

Community
  • 1
  • 1
fantastischIdee
  • 465
  • 2
  • 6
  • 17

2 Answers2

1

Are you referencing IdentityModel package using <PackageReference Include=".../>? If so, I believe you might be running into this known issue: https://github.com/Microsoft/dotnet/blob/master/releases/net472/KnownIssues/613745%20-%20Single-name%20references%20are%20removed%20by%20the%20SDK%20when%20targeting%204.7.2.md

Assuming that's the case, can you please try the workaround listed in there which is basically to add to your .csrpoj the following:

<ItemGroup>
  <PackageReference Include="System.Net.Http" Version="4.3.3">
    <ExcludeAssets>All</ExcludeAssets>
  </PackageReference>
</ItemGroup>

I hope that fixes your issue. Also, do note that we are working on a fix on the VisualStudio side so that you won't need this workaround anymore.

  • This looks like the problem. But the workaround suggested here does not work for me. The IdentityModel is using this PacketReference to reference System.Net.Http: https://github.com/IdentityModel/IdentityModel2/blob/dev/src/IdentityModel/IdentityModel.csproj. And in my project I'm using NuGet to reference System.Net.Http. – fantastischIdee May 23 '18 at 07:06
  • Maybe the workaround should work, but I see some strange behavior of Visual Studio, so I'm not sure. – fantastischIdee May 23 '18 at 09:02
  • After doing the workaround, did you try deleting both your `bin` and `obj` directories? I would make sure both are deleted, and then I would manually call `msbuild yourProject.csproj /t:Restore` in order to regenerate the project.assets.json file. After doing that, I would expect things to work. – Jose Perez Rodriguez May 23 '18 at 19:54
  • I had to remove the NuGet package for System.Net.Http and add a framework reference for the package. It's now part of the .Net-4.7.2 Framwork – fantastischIdee May 27 '18 at 07:10
0

Updating the IdentityModel package to IdentityModel v3.7.0-preview1 helped.

fantastischIdee
  • 465
  • 2
  • 6
  • 17