我想知道为什么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文件中?
发布评论