gpt4 book ai didi

c# - web.config>configuration>runtime>assemblyBinding 中生成的条目的含义/原因是什么?

转载 作者:IT王子 更新时间:2023-10-29 03:51:18 26 4
gpt4 key购买 nike

一段时间以来,我一直在我的 web.config 文件中注意到这个部分,现在我正试图推断出它的确切目的是什么:

  <runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

所以,第一个条目似乎在说:

System.Web.Helpers is the name of a dependent assembly with a public key token of 31bf3856ad364e35. Redirect version 1.0.0.0 through 2.0.0.0 to version 2.0.0.0.

我最好的猜测是,这意味着在 ASP.NET 运行时上下文中执行的任何代码,如果依赖于具有指定名称且版本在指定范围内的程序集,则执行起来就好像它是用指定的编译器编译的一样具有指定公钥的版本。

这是否意味着如果我有一个依赖于类库的 Web 项目并且该类库引用了具有 bindingRedirect 的旧版本程序集,那么代码将像针对较新版本编译的那样执行版本?

最佳答案

Does this mean if I have a web project that depends on a class library and that class library has a reference to an older version of the assembly which has a a bindingRedirect, that the code will execute as if it were compiled against the newer version?

你是对的(我只想说“......代码将执行为如果它引用的是较新的版本”),请参阅 http://msdn.microsoft.com/en-us/library/7wd6ex19%28v=vs.110%29.aspx

"When you build a .NET Framework application against a specific version of a strong-named assembly, the application uses that version of the assembly at run time. However, sometimes you might want the application to run against a newer version of an assembly."

关于c# - web.config>configuration>runtime>assemblyBinding 中生成的条目的含义/原因是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15056499/

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