我注意到我的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是具有公共密钥令牌
31bf3856ad364e35
的依赖程序集的名称。将版本1.0.0.0到2.0.0.0重定向到版本2.0.0.0。
我最好的猜测是,它意味着在ASP.NET运行时上下文中执行依赖于指定名称的程序集并且该程序集的版本在指定范围内的任何代码都会像使用指定版本和指定公钥编译的代码一样执行。
这是否意味着如果我有一个Web项目依赖于一个类库,并且该类库引用了一个具有bindingRedirect的旧版本程序集,那么代码将执行为如果它是针对较新版本编译的吗?