Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding redirects not generated for .NET 4.7.2 transitive dependency chains with System.Buffers #27492

Closed
NickCraver opened this issue Sep 27, 2018 · 7 comments

Comments

@NickCraver
Copy link
Member

We've getting a lot of bug reports on StackExchange.Redis especially with Azure functions and general .exe usage of our library after our v2.0 release based on System.IO.Pipelines.

Some examples:

When a .exe project references a lib that references both System.Buffers 4.5.0 (4.0.3 assembly version) and System.IO.Pipelines (4.5.1), which itself references System.Buffer 4.4.0 (4.0.2 assembly version), what's needed is a redirect from 4.0.2 to 4.0.3. Despite having <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>, this is not generated.

I have a minimal repro of the issue that's easy to test out here: https://github.com/NickCraver/BindingRepro

Here's the reference tree in that repo:

  • BindingRepro
    • RefPipelines
      • System.Buffers 4.5.0 (4.0.3 assembly version)
      • System.IO.Pipelines
        • System.Buffers 4.4.0 (4.0.2 assembly version)

To mitigate this issue for as many people as possible, we have released a new version of Pipelines.Sockets.Unofficial (v1.0.7, the production equivalent of RefPipelines above), which drops our dependency on System.Buffers from 4.5.0 to 4.4.0 (to match System.IO.Pipelines). This fixes our test case and hopefully Azure Functions for others. But this remains a workaround and a very brittle one. The root cause remains. Given .NET 4.7.2 was supposed to eliminate pain here and isn't...what should we be doing? Isn't this something that should be generated? e.g.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.3.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

cc @mgravell @terrajobst @karelz @joperezr

@karelz
Copy link
Member

karelz commented Oct 1, 2018

@joperezr did you get chance to take a look at it?

@joperezr
Copy link
Member

joperezr commented Oct 1, 2018

I see what is happening here. The problem is that System.IO.Pipelines only depends on System.Buffers (4.0.2 version) on the implementation assembly, not on the reference assembly. The task in charge of auto-generating the binding redirects only receives reference assemblies, and based on those, it will decide which redirects you will need. In this case, System.IO.Pipelines reference assembly doesn't depend on System.Buffers, so this task will only see the 4.0.3 version, and won't suggest a binding redirect to fix the conflict.

One possible solution would be to add this target on the consuming .exe project which will basically use the implementation assemblies instead of the reference assemblies so RAR would now suggest the right binding redirects.

We are currently trying to find a solution for this exact problem on this issue: #27470 So you might also find useful information there.

@karelz
Copy link
Member

karelz commented Oct 1, 2018

Thanks @joperezr. Would it make sense to duplicate this issue against the one you linked? (assuming @NickCraver is ok with that)

@joperezr
Copy link
Member

joperezr commented Oct 2, 2018

Yup, I would close this as a dupe of #27470

@joperezr joperezr closed this as completed Oct 2, 2018
@karelz
Copy link
Member

karelz commented Oct 2, 2018

Duplicate of #27470

@karelz
Copy link
Member

karelz commented Oct 2, 2018

@joperezr note that GH recognizes the "Duplicate of #abc" form ;)

@joperezr
Copy link
Member

joperezr commented Oct 2, 2018

😄 noted!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants