question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is polly bringing System.Net.Http 4.2.0.0?

See original GitHub issue

Summary: I’m writing a library that depends on Polly and I discovered that the moment I add polly as a package reference it suddenly brings System.Net.Http 4.2.0.0. This is a very painful well known issue on .net (see this) and I wouldn’t like the consumers of our library to go through it, it forces them to write obscure assembly redirects and if they don’t they may (this is the annoying part) have runtime issues depending on the GAC of the system.

Expected behavior:

Polly shouldn’t bring any System.Net.Http dependencies since is not listed on the dependencies of their nuget package: https://www.nuget.org/packages/Polly/



Actual behaviour:

This is the output of ildasm of a testing library after adding polly as a dependency and using httpclient:

.assembly extern System.Net.Http
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 4:2:0:0
}


Steps / Code to reproduce the problem:

A very simple library project should reproduces this:

TestingPolly.csproj

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <RootNamespace>TestingPolly</RootNamespace>
    <AssemblyName>TestingPolly</AssemblyName>
    <TargetFramework>net461</TargetFramework>
    <Platforms>x64</Platforms>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <!-- Try removing Polly -->
    <PackageReference Include="Polly" Version="7.1.0" />
    <PackageReference Include="System.Net.Http" Version="4.3.3" />
  </ItemGroup>
</Project>

Class1.cs

using System.Net.Http;

namespace TestingPolly
{
    public class Class1
    {
        private HttpClient foo;
    }
}

After building the project, running this command on the output directory of the project (on the VS developer command prompt) with the polly package ildasm TestingPolly.dll /OUT=testingpolly.txt && notepad testingpolly.txt will output this:

.assembly extern System.Net.Http
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 4:2:0:0
}

If polly is removed, ildasm will output this (expected since we depend on System.Net.Http):

.assembly extern System.Net.Http
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 4:1:1:2
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
reisenbergercommented, Nov 27, 2019

Polly v7.2.0 has been published with .NET Framework targets 4.6.1 and 4.7.2 now supported natively as part of the nuget package. Should resolve this issue.

1reaction
hyrmncommented, Sep 8, 2019

@afcruzs We experienced the same. @jglinsek tracked down a way to resolve it in the short-term by adding an explicit binding redirect to downgrade system.net.http to 4.0.0.0

      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>

This may not work for your use case but, if so, it might be a way forward in the short-term. This issue affects us on 461 and 472.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Strange issue with System.Net.Http 4.2.0.0 not found
One simple solution I found that downgrade the target framework for web project to 4.6.
Read more >
ASP.NET error with System.Net.Http 4.2.0.0 : r/dotnet
I am getting ASP.NET 4.0 errors every 1-2 minutes in the Event logs on all our SCCM distribution points since enabling MCC/DOINC and...
Read more >
polly version=7.0.0.0
polly version=7.0.0.0의 정보를 확인해보세요. ... Is polly bringing System.Net.Http 4.2.0.0? · Issue #668 · App-vNext/Polly - GitHub ...
Read more >
Package List
Package List . This is a list of things you can install using Spack. It is automatically generated based on the packages...
Read more >
LTS Haskell 21.7 (ghc-9.4.5)
A semantic web toolkit. syb-0.7.2.4, Scrap Your Boilerplate. sydtest-0.15.1.0, A modern testing framework for Haskell with good defaults and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found