Question

I've noticed in some of my projects there are some binding re-directions where it is redirecting to the same "version" number.

For example:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Reactive" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.10621.0" newVersion="1.0.10621.0" />
      </dependentAssembly>
    </assemblyBinding>
</runtime>

The projects are littered with these redirections.

Is they redundant (and therefore can I remove it)?

I'm not sure how they got into my projects. I didn't type it myself, how did it get there?

Was it helpful?

Solution

Binding redirects are important when two or more seperately built assemblies reference the same library. For example if both your project and an external nuget library both use reactive. You can get into the situation where the different assembies both use different versions of RX which will cause things to break.

what this particular binding redirect is saying is:

if an assembly requests any version of System.Reactive which is less than 1.0.10621.0 just give it the 1.0.10621.0 version

What the binding redirect here does is to make sure that all previous versions of RX are bound to the one you are using in your application. This can prevent binding errors.

Its most likely a nuget package which references RX added this automatically as RX is a fairly common library and hence likely to be used by another assembly.

There are a few problems with doing this kind of thing with libraries,

  • It assumes that the version in the binding redirect is the latest version (in this case if another library used RX 1.1 things would still break)
  • if breaking changes are made assemblies expecting the older version of RX may break if given the new one

Im not a huge fan of automatically adding the binding redirect but it can hide some common problems people have when consuming a package.

TLDR;

In terms of if you can remove the redirect, the answer is probably yes, unless you have multiple versions of RX used by different libraries.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top