Side by side execution of an assembly without touching the client application or application settings.

Side by side execution of an assembly without touching the client application or application settings.

Consider the scenario where there is an assembly vendor. You are using version of that assembly.
Now that assembly vendor has released a new version of the assembly
This new version is to be used by the existing client without recompiling it or changing the config file.
The solution to this problem is the Publisher Policy File.
The assembly vendor will give the setup for the new version( of the assembly and one more assembly contailing the Publisher Policy File. Once These two assemblies are put in GAC the client is ready to use the new version of the assembly.

The Publisher policy can be created in three steps:
Create a config file (Publisher Policy File)
The typical structure of the file

      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <assemblyIdentity name="SbySExeAssembly"
                           culture="Neutral" />
 <!-- The above parameter values can be taken from the assembly properties after puting it in GAC-->
         <!-- Redirecting to version of the assembly. -->
         <bindingRedirect oldVersion=""

Save this file as Policy.config.

Next to create Publisher Policy Assembly from the above config file
Use al.exe (Assembly Linker) to create the assembly.
I created it as folows.
AL /LINK:Policy.config /OUT:policy.1.0.SbySExeAssembly.dll /keyfile:snkFile.snk

  Policy.config  -- COnfig file wich containd redirection directives for the assembly
  policy.1.0.SbySExeAssembly.dll -- Name of the Publisher Policy Assembly File
  this name must have the specified format
  policy.majorNumber.minorNumber.mainAssemblyName.dll (najor and minor numbers of the old assembly)
 snkFile.snk -- keypiar file generated using sn.exe and the same file used to strong name the main assemblies.

Add the publisher policy assembly to the global assembly cache
gacutil /i policy.1.0.SbySExeAssembly.dll

The client starts using the new assembly.

Note: To strong name your assembly set the <Assembly: AssemblyKeyFile("..\..\bin\snkFile.snk")> in your Assembly.vb file

To Test the attachment
Unzip the Files.Zip
Put the SbySExeAssembly.dll (v1.0.0.0) which in folder in GAC and run the client
Next put SbySExeAssembly.dll(v2.0.0.0) in GAC, policy.1.0.SbySExeAssembly.dll in GAC run the client.
Check the output in both the cases

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.