为什么要进行"bindingRedirect"操作?在添加Microsoft.Bcl.Async包后添加到app.config文件中?

编程入门 行业动态 更新时间:2024-10-27 07:28:28
本文介绍了为什么要进行"bindingRedirect"操作?在添加Microsoft.Bcl.Async包后添加到app.config文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想知道为什么nuget在安装Microsoft.Bcl.Async之后将以下代码添加到我的应用程序app.config文件中:

I was wondering why nuget added the following code to my applications app.config file, after installing the Microsoft.Bcl.Async:

<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-2.5.19.0" newVersion="2.5.19.0" /> </dependentAssembly> </assemblyBinding> </runtime>

如果我从配置中删除此XML元素,则该应用将无法正常运行.

If I remove this XML-element from the config, the app will not work properly.

据我了解,我们可以使用bindingRedirect使应用程序加载程序集的新版本或旧版本,以防编译EXE时使用的版本消失. 但是我恰好使用的版本是2.5.19.0,那么为什么我需要重定向?

As far as I understand it, we can use the bindingRedirect to make the app load a newer or older version of an assembly in case the version we were using when compiling the EXE is gone. However I am using exactly the version 2.5.19.0, why would I need a redirect then?

为什么需要这个bindingRedirect?

Why do I need this bindingRedirect?

推荐答案

程序集Microsoft.Threading.Tasks和Microsoft.Threading.Tasks.Extensions仍引用System.Runtime和System.Threading.Tasks的v1.5.11.0.

The assemblies Microsoft.Threading.Tasks and Microsoft.Threading.Tasks.Extensions are still referencing v1.5.11.0 of System.Runtime and System.Threading.Tasks.

在没有bindingRedirect的情况下,Microsoft.*程序集将尝试加载旧版本的System.*程序集,该程序将失败.

Without the bindingRedirect, the Microsoft.* assemblies would try to load an old version of the System.* assemblies, which would fail.

更多推荐

为什么要进行"bindingRedirect"操作?在添加Microsoft.Bcl.Async包后添加到app.config文件中?

本文发布于:2023-11-12 02:57:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580308.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   文件   Microsoft   quot   bindingRedirect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!