Load binding redirects from *.dll.config when loading an assembly dynamically


I'm developing a windows service that is dynamically loading an DLL which contains the actual logic for that service. It is loaded using Assembly.LoadFrom(...). That assembly is referencing Microsoft.Graph on NuGet which in turn requires some other libraries, System.ValueTuple in particular. When compiling the versions are resolved properly, but when loading the assembly it tries to find version when is present.

So I created a binding redirect like follows:

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

I enabled FusionLog and it told me it wasn't even loading this file (I put it next to the DLL with the name .dll.config). How can I use those binding redirects in connection with Assembly.LoadFrom()?

The fusion log (sorry it's german):

*** Protokolleintrag für Assembly-Binder  (06.08.2019 @ 09:14:03) ***

Fehler bei diesem Vorgang.
Ergebnis der Bindung: hr = 0x80070002. Das System kann die angegebene Datei nicht finden.

Der Assemblymanager wurde geladen aus:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Als EXE-Datei ausgeführt.  C:\Program Files (x86)\iSM\biCube\services\BiCube.Services.Host.exe
--- Ein detailliertes Fehlerprotokoll folgt. 

=== Zustandsinformationen vor Bindung ===
LOG: DisplayName = System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Appbase = file:///C:/Program Files (x86)/iSM/biCube/services/
LOG: Ursprünglicher PrivatePath = NULL
LOG: DynamicBase = NULL
LOG: CacheBase = NULL
LOG: AppName = BiCube.Services.Host.exe
Aufruf von Assembly : Microsoft.Graph.Core, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
LOG: Diese Bindung startet im default-Load-Kontext.
LOG: Es wurde keine Anwendungskonfigurationsdatei gefunden.
LOG: Die Hostkonfigurationsdatei wird verwendet: 
LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config wird verwendet.
LOG: Verweis nach der Richtlinie: System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: Die Suche im GAC war nicht erfolgreich.
LOG: Download von neuem URL file:///C:/Program Files (x86)/iSM/biCube/services/System.ValueTuple.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/iSM/biCube/services/System.ValueTuple/System.ValueTuple.DLL.
LOG: Download von neuem URL file:///C:/Program Files (x86)/iSM/biCube/services/System.ValueTuple.EXE.
LOG: Download von neuem URL file:///C:/Program Files (x86)/iSM/biCube/services/System.ValueTuple/System.ValueTuple.EXE.
LOG: Fehler bei allen Such-URLs.
asked on Stack Overflow Aug 6, 2019 by S. Mense

1 Answer


It could be related to the entry - <bindingRedirect oldVersion="" newVersion="" /> As per that only versions 0 to 4.0.1 will be redirected to 4.0.2. You should keep the oldVersion=""

answered on Stack Overflow Feb 22, 2021 by Saint

User contributions licensed under CC BY-SA 3.0