Strange section in web.config
I noticed this in my web.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersio开发者_如何学JAVAn="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
What exactly is this?
Thanks
This is a binding redirect and is the escape hatch from .NET's usual desire to bind a referenced assembly to the exact version it was built against. Normally, if a program is built against version X of a particular DLL, then .NET will try to load version X, even if a newer version is available. This is to avoid surprises due to changes of behaviour (including bug fixes!) in newer versions. A binding redirect specifies another policy, saying that .NET should load the version specified in "newVersion" instead.
This particular redirect tells the program: when an assembly tries to load a version of System.Web.Extensions.dll with a version number between 1.0.0.0 and 1.1.0.0, don't load the version that was asked for: load version 3.5.0.0 instead.
(In this case, "program" == "Web site.")
It's usually used to force a program to use a more recent DLL version than the one it was built against, without recompiling it against the more recent version.
According to this link, it allows you to use a newer version of an assembly.
My understanding is that it's telling your application to use version 3.5 of System.Web.Extensions, instead of 1.0 or 1.1. In other words, "where 1.0 or 1.1 is needed, use 3.5 instead".
In short it specifies that if the application is dependent on System.Web.Extensions
or System.Web.Extensions.Design
, versions 1.0.0.0 to 1.1.0.0, the system should load and use version 3.5.0.0 of the assembly. You can read about this in the documentation for dependentAssembly
and bindingRedirect
.
http://msdn.microsoft.com/en-us/library/0ash1ksb.aspx
It is basically used to tell the program to load 3.5.0.0 of System.Web.Extenstions.dll if it is trying to load 1.0.0.0 or 1.1.0.0
精彩评论