gpt4 book ai didi

c# - 使用绑定(bind)重定向降级(使用较低版本的库)

转载 作者:太空狗 更新时间:2023-10-29 23:34:08 24 4
gpt4 key购买 nike

我使用的是旧版本的 NHibernate (v3.0.0.1001),我一直坚持使用它,因为新的 LINQ 提供程序破坏了我的很多查询(稍后我将尝试修复)。我想更新一个使用 NHibernate v3.1.0.4000 的库。

我尝试在 App.config 中添加绑定(bind)重定向:

<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.1.0.4000" newVersion="3.0.0.1001"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

但是当我编译时,我得到:

错误 CS1705:程序集“My3rdPartyDll,Version=0.5.0.170,Culture=neutral,PublicKeyToken=null”使用“NHibernate,Version=3.1.0.4000,Culture=neutral,PublicKeyToken=aa95f207798dfdb4”,它具有更高版本比引用程序集 'NHibernate, Version=3.0.0.1001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'

是否可以使用绑定(bind)重定向指向降级?

最佳答案

您可以使用 probing元素指定一个特定的文件夹来查找dll,然后您可以将dll 传递到该文件夹​​中。

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Assemblies"/>
</assemblyBinding>
</runtime>

您还可以指定要使用的特定程序集,这正是我认为您正在寻找的。

  <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WorkflowLibrary1" publicKeyToken="8afb6d596a769080" />
<codeBase version="1.0.0.0" href="Version_1_0_0_0/WorkflowLibrary1.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>

Link对此进行了详细介绍。

关于c# - 使用绑定(bind)重定向降级(使用较低版本的库),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6626874/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com