我想知道爲什麼的NuGet下面的代碼添加到我的應用程序app.config
文件,安裝後Microsoft.Bcl.Async
:爲什麼在添加Microsoft.Bcl.Async包之後將「bindingRedirect」添加到app.config文件中?
<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元素,應用程序將無法正常工作。
據我瞭解,我們可以使用bindingRedirect
來使程序加載程序集的更新或更舊版本,以防在編譯EXE時使用的版本消失。
但是,我正在使用的版本2.5.19.0
,爲什麼我需要重定向呢?
爲什麼爲什麼要用這種bindingRedirect
?
我有類似的情況,其中重定向的程序集沒有使用其他地方,但仍然需要bindingredirect嗎? - 或者我可以斷言,如果程序集的舊版本沒有被引用,那麼綁定重定向根本就不需要。 – zinking