Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.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# .NET程序集依赖项版本回退_C#_.net_Dependencies_Assemblies - Fatal编程技术网

C# .NET程序集依赖项版本回退

C# .NET程序集依赖项版本回退,c#,.net,dependencies,assemblies,C#,.net,Dependencies,Assemblies,因此,我有一个GUI应用程序(C#.NET 4.0),我们将其称为main.exe。它依赖于类库,我们称之为library.dll(C#.NET 3.5),附带了几个版本(我们将说1.1.0.0、1.2.0.0和1.3.0.0)。将在目标环境的GAC中安装一个(或多个)版本的library.dll。所有涉及的程序集都具有强名称 我的目标是让main.exe使用library.dll的任何可用版本,如果可能的话,尝试使用最新版本。然而,我的工作受到一些限制: library.dll是现有程序集,此

因此,我有一个GUI应用程序(C#.NET 4.0),我们将其称为main.exe。它依赖于类库,我们称之为library.dll(C#.NET 3.5),附带了几个版本(我们将说1.1.0.0、1.2.0.0和1.3.0.0)。将在目标环境的GAC中安装一个(或多个)版本的library.dll。所有涉及的程序集都具有强名称

我的目标是让main.exe使用library.dll的任何可用版本,如果可能的话,尝试使用最新版本。然而,我的工作受到一些限制:

  • library.dll是现有程序集,此时无法更改

  • main.exe(可以更改)是使用硬依赖项设计的,Assembly.LoadWithPartialName()或类似的内容将是禁止性的设计更改

  • 最理想的情况是,我正在寻找一种类似于程序集重定向的机制,但是我还没有找到一种方法来为这种场景正确地欺骗配置

    考虑到我们是根据库1.1.0.0构建的,如果这些重定向设置中的任何一个都能正常工作就好了,但遗憾的是它们不能正常工作

        <?xml version ="1.0"?>
        <configuration>
          <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
              <dependentAssembly>
                <!-- 
                    intent here is to provide a range of possible installed assemblies
                    but .NET does not allow ranges in newVersion 
                -->
                <assemblyIdentity name="library" publicKeyToken="..." culture="neutral"/>
                <bindingRedirect oldVersion="1.1.0.0" newVersion="1.1.0.0-1.3.0.0"/>
              </dependentAssembly>
              <dependentAssembly>
                <!-- 
                    intent here is to provide a fallback list of possible installed assemblies
                    but .NET ignore all but the first bindingRedirect
                -->
                <assemblyIdentity name="library" publicKeyToken="..." culture="neutral"/>
                <bindingRedirect oldVersion="1.3.0.0" newVersion="1.1.0.0"/>
                <bindingRedirect oldVersion="1.2.0.0" newVersion="1.1.0.0"/>
                <bindingRedirect oldVersion="1.1.0.0" newVersion="1.1.0.0"/>
              </dependentAssembly>
            </assemblyBinding>
          </runtime>
        </configuration>