Customizing the Microsoft .NET Framework Common Language Runtime

When a strong-named assembly is loaded into an application domain, the default versioning rules provided by the CLR make sure that the exact version of the assembly being referenced is the one that gets loaded. This default behavior lets you enjoy the highest degree of confidence that the application as a whole will run properly because only the set of assemblies that were built and tested together will be loaded. However, there are some cases in which you might want more flexibility. So the CLR provides a version policy system that allows the application consuming the assembly, the author, or the assembly or machine administrator to change which version of an assembly gets loaded given a particular reference. By default, the version policy system is enabled in the sense that if any of these versioning rules (termed binding redirects) are in place, the CLR will use them when determining which version of an assembly to load.

Although the version policy system is beneficial for the vast majority of application scenarios, I could imagine cases in which the creator of an application domain might want to disable one or more of the available policy levels. The AppDomainSetup object includes two properties that enable you to specify such customizations. The first of these properties, DisallowBindingRedirects, causes all version policy statements made in the application configuration file to be ignored. You might find this property useful to ensure that a consistent set of assemblies is always running in your domain, for example. The second property, DisallowPublisherPolicy, causes all publisher policy statements to be ignored for shared assemblies loaded into the application domain. This property is also used in environments where the creator of the application domain wants very tight control over the versions of the assemblies that are loaded. For example, by using DisallowBindingRedirects and DisallowPublisherPolicy together, the creator of a domain can ensure that only the administrator of the machine is allowed to alter which versions of shared assemblies are loaded into the domain.

    Категории