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 1.0.0.0 of that assembly.
Now that assembly vendor has released a new version of the assembly 2.0.0.0.
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(2.0.0.0) 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

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

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

Here
  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 1.0.0.0 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

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.
Publish