Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 动态加载程序集时,加载绑定会从*.dll.config重定向_C#_Visual Studio - Fatal编程技术网

C# 动态加载程序集时,加载绑定会从*.dll.config重定向

C# 动态加载程序集时,加载绑定会从*.dll.config重定向,c#,visual-studio,C#,Visual Studio,我正在开发一个windows服务,它动态加载一个DLL,其中包含该服务的实际逻辑。它是使用Assembly.LoadFrom(…)加载的。该程序集正在引用NuGet上的Microsoft.Graph,而NuGet又需要一些其他库,尤其是System.ValueTuple。编译时,版本已正确解析,但加载程序集时,它会在存在4.0.2.0时尝试查找版本4.0.1.0 因此,我创建了一个绑定重定向,如下所示: <?xml version="1.0" encoding="utf-8"?> &

我正在开发一个windows服务,它动态加载一个DLL,其中包含该服务的实际逻辑。它是使用
Assembly.LoadFrom(…)
加载的。该程序集正在引用NuGet上的Microsoft.Graph,而NuGet又需要一些其他库,尤其是System.ValueTuple。编译时,版本已正确解析,但加载程序集时,它会在存在4.0.2.0时尝试查找版本4.0.1.0

因此,我创建了一个绑定重定向,如下所示:

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

它可能与条目有关-
根据,只有版本0到4.0.1将重定向到4.0.2。
您应该保留
oldVersion=“0.0.0-4.0.2.0”

在哪个程序集中定义了绑定重定向?使用assembly.LoadFrom()调用的程序集。它包含了逻辑,也是我写的。名称在此处不重要。正在加载的程序集正在引用Microsoft.Graph,而该程序集又无法加载System.ValueTuple。
*** 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=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
 (Fully-specified)
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=1.15.0.0, 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=4.0.1.0, 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.