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 usin

ITPro Today

February 6, 2006

2 Min Read
ITPro Today logo

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


  
     
      
                                    publicKeyToken="88b81ca02e82e359"
                           culture="Neutral" />
 
        
                                   newVersion="2.0.0.0"/>
      
     
  

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

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like