引用多个版本的同一总成多个、总成、版本

2023-09-04 05:40:51 作者:惡_性_導_師

是否有可能有多个版本的强烈同一进程名称程序集加载的一样吗?有大量的类似的问题,但答案似乎不工作。

我问的原因是,我们需要使用更新版本(4.0.0.0) SomeAssembly.dll ,但一些引用的DLL依赖于该DLL的以上(3.0.0.0)版本。

我用下面的程序集绑定重定向配置都试过了,但结束了的编辑的错误,因为我的程序集依赖于该DLL的较新版本,这个配置是完全重写的联系,只有 3.0.0.0版正在使用。我希望它可以在运行时出现故障。正在使用的配置文件编译器在这里?

版本4.0.0.0 在项目中引用按通常。 版本3.0.0.0 复制到项目输出。

 <运行>
    < assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
      < dependentAssembly>
        < assemblyIdentity名=SomeAssembly公钥=123文化=中性/>
        < bindingRedirect oldVersion =3.0.0.0NEWVERSION =3.0.0.0/>
        < codeBase的版本=4.0.0.0HREF =斌/ SomeAssembly.dll/>
        < codeBase的版本=3.0.0.0HREF =SomeAssembly.dll/>
      < / dependentAssembly>
    < / assemblyBinding>
  < /运行>
 

解决方案

尝试删除线

 < bindingRedirect oldVersion =3.0.0.0NEWVERSION =3.0.0.0/>
 

,把集会的BIN文件夹内单独的文件夹。例如,

 < dependentAssembly>
    < assemblyIdentity名=SomeAssembly公钥=123文化=中性/>
    < codeBase的版本=4.0.0.0HREF =V4 \ SomeAssembly.dll/>
    < codeBase的版本=3.0.0.0HREF =V3 \ SomeAssembly.dll/>
  < / dependentAssembly>
 
Indirect函数 批量引用多个工作表的数据,就靠它

Is it possible to have multiple versions of the same strongly named assembly loaded in the same process? There is plenty of similar questions, but non of the answers seem to work.

The reason I'm asking is we need to use newer version (4.0.0.0) of SomeAssembly.dll, but some referenced dlls depend on the older version (3.0.0.0) of this dll.

I have tried using the below assembly binding redirection configuration, but ended up with compilation errors, because my assemblies depend on a newer version of the dll and this configuration is completely overriding the linkage and only version 3.0.0.0 is being used. I would expect this to fail at run-time. Is compiler using the config files here?

Version 4.0.0.0 is referenced in project as per usual. Version 3.0.0.0 is copied to the project output.

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="SomeAssembly" publicKeyToken="123" culture="neutral" />
        <bindingRedirect oldVersion="3.0.0.0" newVersion="3.0.0.0" />
        <codeBase version="4.0.0.0" href="bin/SomeAssembly.dll" />
        <codeBase version="3.0.0.0" href="SomeAssembly.dll" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

解决方案

Try removing line

<bindingRedirect oldVersion="3.0.0.0" newVersion="3.0.0.0" />

and put assemblies in separate folder inside BIN folder. e.g.

<dependentAssembly>
    <assemblyIdentity name="SomeAssembly" publicKeyToken="123" culture="neutral" />
    <codeBase version="4.0.0.0" href="V4\SomeAssembly.dll" />
    <codeBase version="3.0.0.0" href="V3\SomeAssembly.dll" />
  </dependentAssembly>