这不是问题,而是关于程序集绑定(bind)重定向工作的一般理解问题。
查询
只有大版本有变化,新旧版本才会变化吗?
<dependentAssembly>
<assemblyIdentity name="FooBar"
publicKeyToken="32ab4ba45e0a69a1"
culture="en-us" />
<bindingRedirect oldVersion="7.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
最佳答案
为什么需要绑定(bind)重定向?假设您有引用库 B 的应用程序 A,以及版本 1.1.2.5 的库 C。库 B 反过来也引用库 C,但版本为 1.1.1.0。现在我们发生了冲突,因为您不能在运行时加载同一程序集的不同版本。要解决此冲突,您可以使用绑定(bind)重定向,通常指向新版本(但也可以指向旧版本)。您可以通过将以下内容添加到应用程序 A 的 app.config 文件中,在 configuration > runtime > assemblyBinding
部分下(有关完整配置文件的示例,请参阅 here):
<dependentAssembly>
<assemblyIdentity name="C"
publicKeyToken="32ab4ba45e0a69a1"
culture="en-us" />
<bindingRedirect oldVersion="1.1.1.0" newVersion="1.1.2.5" />
</dependentAssembly>
您还可以指定要映射的版本范围:
<bindingRedirect oldVersion="0.0.0.0-1.1.1.0" newVersion="1.1.2.5" />
现在引用1.1.1.0版本的C编译的库B在运行时将使用1.1.2.5版本的C。当然,你最好确保库 C 是向后兼容的,否则这可能会导致意想不到的结果。
您可以重定向任何版本的库,而不仅仅是主要版本。
https://stackoverflow.com/questions/58183520/
相关文章:
android-studio - Android studio 在执行 lint 时找不到 kotl
angular - 重新加载页面后保持元素位置 - 拖放 cdk Angular 7
python - 将部分训练的 scikit-learn 模型存储或检查点到磁盘
python - 使用 Python 类型模块指定序列或列表的长度
bash - 如何使用 Shell 脚本在 mac 中覆盖环境变量
python - 如何在 keras 中训练顺序模型,给出一个列表作为输出和输入?
reactjs - 错误 : [mobx] Computed values are not allo