Binding Redirects

This forum is meant for questions and discussions about the X# language and tools
Post Reply
TrevorLE
Posts: 266
Joined: Thu Apr 21, 2016 12:02 pm
Location: Australia

Binding Redirects

Post by TrevorLE »

Hi Guys

I have an issue where a couple of different third party dll's are using common files such as System.Net.Http and when building I am getting warnings about 2 different versions being referenced.

I have found that if I ignore the warnings - it works so I am assuming the code I am using is using code in the common dll that is still compatible etc.

I see via google C# someone addressed the same issue by creating an AssemblyName.exe.cfg file with details like the below, but I tried that in my project to no avail so I assume I am not doing it correctly

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<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>
</assemblyBinding>
</runtime>
</configuration>

What is the best way in an X# project to tell it to resolve one version to another version and if it is along the lines of the above, exactly where does the configuration XML need to be placed?
(I already have Auto generate binding redirects ticked)

thanks in advance
Trevor
User avatar
wriedmann
Posts: 3688
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Binding Redirects

Post by wriedmann »

Hi Trevor,
I managed it to resolve a sort of DLLhell in an X# application by moving the DLLs in a different directory and loading then from there using a System.Reflection.Assembly.LoadFrom( cFileName ) call.
To explain it better: I had a DLL that loaded an incompatible version of that what my application needs. I created a subdirectory oy my application and moved the DLL there, complete with their dependency, and on program start, I load the 3rd party manually from this directory.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
Chris
Posts: 4652
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Binding Redirects

Post by Chris »

Hi Trevor,

Can you please show the full error message, just in case it has some important information in it about the exact source of conflict?
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
TrevorLE
Posts: 266
Joined: Thu Apr 21, 2016 12:02 pm
Location: Australia

Binding Redirects

Post by TrevorLE »

Chris

below are the 2 warnings we get.  I did try changing the project properties to suppress the MSB3277 warning message but it still appears and that wasn't really addressing the issue anyway.  The 2 files log4net and Newtonsoft.json we have as direct references in our projects as some 3rd party dlls use them, but after adding references for the latest DevExpress version we started getting the below conflicts.  The program all works fine so I assume we arent using anything that touches any features that arent in the earlier versions so I didnt really want to start changing dlls etc as everything is already working if I could avoid it as that would then require rolling changes out to all client sites etc.
thanks
Trevor

C:Program Files (x86)Microsoft Visual Studio2019ProfessionalMSBuildCurrentBinMicrosoft.Common.CurrentVersion.targets(2203,5): warning MSB3277: Found conflicts between different versions of "log4net" that could not be resolved.
There was a conflict between "log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" and "log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a".
    "log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" was chosen because it was primary and "log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" was not.
    References which depend on "log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" [W:CommonOptionsResourcesDllslog4net.dll].
        W:CommonOptionsResourcesDllslog4net.dll
          Project file item includes which caused reference "W:CommonOptionsResourcesDllslog4net.dll".
            log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a
    References which depend on "log4net, Version=2.0.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" [].
        W:CommonOptionsResourcesDllsDevExpress.XtraReports.v22.2.Design.Tool.dll
          Project file item includes which caused reference "W:CommonOptionsResourcesDllsDevExpress.XtraReports.v22.2.Design.Tool.dll".
            DevExpress.XtraReports.v22.2.Design.Tool, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
C:Program Files (x86)Microsoft Visual Studio2019ProfessionalMSBuildCurrentBinMicrosoft.Common.CurrentVersion.targets(2203,5): warning MSB3277: Found conflicts between different versions of "Newtonsoft.Json" that could not be resolved.
There was a conflict between "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed".
    "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" was chosen because it was primary and "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" was not.
    References which depend on "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" [W:CommonOptionsResourcesDllsNewtonsoft.Json.dll].
        W:CommonOptionsResourcesDllsNewtonsoft.Json.dll
          Project file item includes which caused reference "W:CommonOptionsResourcesDllsNewtonsoft.Json.dll".
            Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
    References which depend on "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" [].
        W:CommonOptionsResourcesDllsDevExpress.XtraReports.v22.2.Design.Tool.dll
          Project file item includes which caused reference "W:CommonOptionsResourcesDllsDevExpress.XtraReports.v22.2.Design.Tool.dll".
            DevExpress.XtraReports.v22.2.Design.Tool, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
        W:CommonOptionsResourcesDllsMicrosoft.Graph.dll
          Project file item includes which caused reference "W:CommonOptionsResourcesDllsMicrosoft.Graph.dll".
            Microsoft.Graph, Version=1.21.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        W:CommonOptionsResourcesDllsMicrosoft.Graph.Core.dll
          Project file item includes which caused reference "W:CommonOptionsResourcesDllsMicrosoft.Graph.Core.dll".
            Microsoft.Graph.Core, Version=1.19.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
            Microsoft.Graph, Version=1.21.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        C:WINDOWSMicrosoft.NetassemblyGAC_MSILDevExpress.XtraReports.v22.2.Design.VSCorev4.0_22.2.4.0__b88d1754d700e49aDevExpress.XtraReports.v22.2.Design.VSCore.dll
          Project file item includes which caused reference "C:WINDOWSMicrosoft.NetassemblyGAC_MSILDevExpress.XtraReports.v22.2.Design.VSCorev4.0_22.2.4.0__b88d1754d700e49aDevExpress.XtraReports.v22.2.Design.VSCore.dll".
            DevExpress.XtraReports.v22.2.Design.Tool, Version=22.2.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
User avatar
Chris
Posts: 4652
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Binding Redirects

Post by Chris »

Hi Trevor,

Thanks for the info! Unfortunately the messages do not specify explicitly in which folders exist the different versions of the dlls, so it's not as straightforward as I had hoped. Since it is all working well, you can ignore this, but of course it would be better to resolve this at some time, by removing all references and adding them again, making sure all projects use the same dlls. And if 3rd party dlls depend on some dlls, then reference only those specific dlls and not other versions of them.
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply