Publisher Policy revisit

There are several layers of binding policies in .Net framework. App Policy, Publisher Policy, Host Policy and Admin policy.


Policies are defined in config files. The config files are parsed once per AppDomain. The parsed result is used later for binding.


--- Except Publisher Policy.


Publisher Policy is per assembly. Unless an assembly load is issued, we will not look for publisher policy for that assembly


This creates an interesting problem. For the same appdomain, if a publisher policy is installing to the system, depending on whether the installation finishes before or after the assembly load, the assembly load may or may not see the publisher policy.


This ad-hoc publisher policy look up approach also makes domain neutral assemblies sharing much more challenging. There is no way to look at two appdomains and say those two appdomains have exactly the same binding policies.


To solve those problems, we made a change in .Net framework 2.0 for publisher policy look up. (Conceptually), on appdomain creation, we cache all the publisher policies in the system. We will only look at the publisher policies cache on binding policy resolution. If there is publisher policy change during the appdomain lifetime, it will not be seen by the appdomain.


This change gives us a much more consistent policy model, and enables us to make the right assembly sharing decision.


The caching is done at the time when publisher policy is installed/uninstalled, so that the runtime perf penalty is minimum.

Comments (5)

  1. fred says:

    All examples I have seen use the /link option (of AL.EXE) to build a publisher policy assembly from the publisher policy xml, thereby forcing the consumer to always have the xml file in the same directory as the policy assembly in order to install the policy assembly in the GAC. Is it possible to use the /embed option, so the user does not need the xml? (Does not work, in my experience.)


  2. Fred,

    Sorry there is no way to do that.

  3. Raj says:

    Dropping a publisher policy assembly into the GAC requires you to do it from the folder containing the .config file which was used to create the published policy assembly.

    So on the developer’s machine one can run gacutil /i and install the policy into the GAC.

    How does one do it using the installer. Or does one have to run gacutil on the end-user’s computer to install the policy assembly into the GAC?

  4. Publisher policy assembly is simply a multi-file assembly. You install it the same way as other multi-file assemblies.

Skip to main content