The first step in binding to an assembly is to retrieve the application configuration file, if one exists. For client executables, the configuration file resides in the same directory as the executable and has the name of the exe (minus the .exe extension) + .cfg. So the configuration file for c:\program files\myapp\myapp.exe would be c:\program files\myapp\myapp.cfg. In the browser scenario, the configuration file must explicitly be pointed to in the html file (see Code Download Using IE5 for details). Specifying version policy at the application level currently cannot be done in ASP+ scenarios.
The <BindingPolicy> tag in the application configuration file can be used to redirect the reference to a particular version, or all versions, of an assembly to a different version (a complete description of the schema for BindingPolicy is available in Versioning). These version polices only apply when the reference is to an assembly with a shared name. References to private assemblies cannot have such policies applied. In fact, version checking is not done at all for binds to private assemblies.
The following entry from an application configuration file redirects references to all versions of an assembly called calcr to version 2.1.0.0:
<BindingPolicy> <BindingRedir Name="Calcr" Originator="32ab4ba45e0a69a1" Version="*" VersionNew="2.1.0.0" UseLatestBuildRevision="yes"/> </BindingPolicy>
If a version redirect for the requested assembly is encountered, the AssemblyResolver proceeds as if the original bind had requested the version specified in the redirect. In the example above, the bind will continue as if the original bind request was for version 2.1.0.0 of calcr.
The default behavior of the AssemblyResolver is to match versions based on major and minor number, and take the latest build and revision numbers (see Versioning for the semantics of each portion of the version number). The policy of taking the latest build and revision is often referred to as Automatic QFE Policy. This QFE policy allows software vendors to release critical bug fixes without requiring dependent applications to be rebuilt or reconfigured. It is worth noting that this policy is implicit in that there is nothing that NGWS runtime does to enforce that a QFE is in fact backward compatible with the version it is replacing. Also, we never implicitly take the latest major and minor numbers because they are, by definition, incompatible with what is being requested.
The automatic QFE policy can be overridden in one of two ways using the application configuration file. First, QFE policy can be disabled for references to particular assemblies using the “UseLatestBuildRevision” attribute of BindingPolicy. For example, the following entry turns off QFE policies for all references to an assembly named Parser:
<BindingPolicy> <BindingRedir Name="Parser" Originator="32ab4ba45e0a69a1" Version="*" VersionNew="12.3.0.0" UseLatestBuildRevision="no"/> </BindingPolicy>
Second, the application configuration file can be used to specify that all references to assemblies made within the application should bind to the exact versions that were present at build time, as recorded in the manifest. This is called Safe Mode. When running an app in Safe Mode, automatic QFE policy is never applied. Safe Mode is turned on using the <BindingMode> tag (see Versioning for detailed schema).
<BindingMode> <AppBindingMode Mode="safe"/> </BindingMode>