是什么意思/原因在web.config中&GT生成的条目;结构>&运行GT; assemblyBinding? [英] What is the meaning/reason for the generated entries in web.config>configuration>runtime>assemblyBinding?

查看:273
本文介绍了是什么意思/原因在web.config中&GT生成的条目;结构>&运行GT; assemblyBinding?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我一会儿web.config文件中注意到了这一部分,现在我想弄明白究竟的宗旨是:

 <&运行GT;
    < assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Helpers公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-2.0.0.0NEWVERSION =2.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.Mvc公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =0.0.0.0-4.0.0.0NEWVERSION =4.0.0.0/>
      < / dependentAssembly>
      < dependentAssembly>
        < assemblyIdentity名称=System.Web.WebPages公钥=31bf3856ad364e35/>
        < bindingRedirect oldVersion =1.0.0.0-2.0.0.0NEWVERSION =2.0.0.0/>
      < / dependentAssembly>
    < / assemblyBinding>
  < /运行>

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


  

System.Web.Helpers是一个依赖程序集的名称与公用
   31bf3856ad364e35 的密钥令牌。通过重定向版本1.0.0.0
  2.0.0.0 2.0.0.0到版本。


我最好的猜测是,它是指任何code在这取决于使用指定的名称也已经在指定范围内的一个版本的程序集的ASP.NET运行时的上下文中执行的执行过程,如果它被编译与指定公钥指定的版本。

这是否意味着,如果我有依赖于一个类库和类库有一个旧版本有AA bindingRedirect组件的参考Web项目,即code将执行,如果它被编译对更新的版本?


解决方案

  

这是否意味着,如果我有依赖于一个类库Web项目
  和类库有一个旧版本的参考
  组件,其具有一个bindingRedirect,即code将执行作为
  如果它是对新版本编译的?


您是不是正确的(我只想说:......在code将执行作为
如果它被引用的新版本),请参阅http://msdn.microsoft.com/en-us/library/7wd6ex19%28v=vs.110%29.aspx


  

当你建立针对特定的.NET Framework应用程序
  一个强命名程序集的版本,应用程序使用该版本
  在运行时的装配。但是,有时您可能希望
  应用程序针对的组件的新版本上运行。


I've noticed this section in my web.config files for a while and I'm now trying to reason out what exactly the purpose is:

  <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>

So, the first entry seems to say:

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.

My best guess is that it means any code executing in the context of the ASP.NET run time that depends on an assembly with the specified name which also has a version in the specified range executes as if it were compiled with the specified version with the specified public key.

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?

解决方案

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?

You have it right (I would just say "...the code will execute as if it were referencing the newer version"), see 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."

这篇关于是什么意思/原因在web.config中&GT生成的条目;结构&gt;&运行GT; assemblyBinding?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆