Skip to content

Wrong version binding redirect is generated when referencing a PCL dependency that uses System.Xml.Linq #703

Closed

Description

@reijerh

To reproduce:
Create a .NET 4.5 (WPF?) project with:

paket.dependencies:

redirects: on
framework: net45
source https://www.nuget.org/api/v2

paket.references:
FluentAssertions

This will result in app.config binding redirects:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="FluentAssertions.Core" publicKeyToken="33f2691a05b67b6a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="FluentAssertions" publicKeyToken="33f2691a05b67b6a" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.CSharp" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.5.0" newVersion="2.0.5.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Xml.Linq" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
  </dependentAssembly>
</assemblyBinding>

The problem is that for Microsoft.CSharp and System.Xml.Linq it redirects to 5.0.5.0, while it should redirect to 4.0.0.0. The 5.0 versions seem to be Silverlight versions according to Google. It also probably shouldn't add a redirect for Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight at all.

When you now add another package that references an older version of these DLLs, e.g. Kent.Boogaart.Converters, the application will crash with an exception like:

{System.TypeInitializationException: The type initializer for 'Kent.Boogaart.HelperTrinity.ExceptionHelper' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Linq, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.
   --- End of inner exception stack trace ---
   at Kent.Boogaart.HelperTrinity.ExceptionHelper..cctor()
   --- End of inner exception stack trace ---
   at Kent.Boogaart.HelperTrinity.ExceptionHelper..ctor(Type forType)
   at Kent.Boogaart.Converters.ExpressionConverter..cctor()}

Just FYI, this is in FluentAssertions.nuspec:

<frameworkAssemblies>
  <frameworkAssembly assemblyName="System.Xml" targetFramework="" />
  <frameworkAssembly assemblyName="System.Xml.Linq" targetFramework="" />
</frameworkAssemblies>

Activity

  1. forki commented on Mar 22, 2015

    @forki
    Member
  2. isaacabraham commented on Mar 22, 2015

    @isaacabraham
    Contributor

    Fairly sure that this is related to #711 i.e. we're reading during binding redirects generation for dependencies that aren't appropriate for the selected framework.

  3. reijerh commented on May 4, 2015

    @reijerh
    Author

    Is this caused by FluentAssertions's packaging configuration? (i.e: should I create an issue at their repo?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions