GAC assembly versioning policy QFE behavior

G

Guest

I am trying to get QFE (Quick Fix Engineering) working with an assembly
installed in the GAC. I have two books that claim if two different version
of the assembly are installed in the GAC -AND- they vary only by revision
number, then the default policy is to load the higher number version. I am
not able to reproduce this behavior in practice.

My test case is simple. I wrote a class with AssemblyVersion 1.0.0.1.
Installed into GAC. Created a console application that reference this
assembly to verify it works. I then created a second assembly (with the same
assembly name) and made it version 1.0.0.2. I installed this into the GAC.
I verified that both version exist by using the GUI viewer for the GAC. I
then reran my console application without recompiling. It is still using the
1.0.0.1 version (the class I built returns the version number so I know this
for certain).

So my question is why won't won't the CLR recognize that a newer version is
available and automatically start using it?

Thank You

James Tyner
..NET Developer
 
M

Mattias Sjögren

I have two books that claim if two different version
of the assembly are installed in the GAC -AND- they vary only by revision
number, then the default policy is to load the higher number version. I am
not able to reproduce this behavior in practice.

Your books are wrong, and the behaviour you've observed is the way
it's designed to work. Unless you tell it otherwise, the CLR will only
bind to the exact version that was referenced.


Mattias
 
L

Leon Lambert

Following is a small part of an email i sent to some of our developers
to handle this same issue. Hopefully it gives you enough information to
at lease figure out where to look.
----------------------------
There is a way to create and register an item called a Publisher Policy
Assembly. You can then redirect all users of a dll to a new version.
Following are the steps.

First create the configuration file. This has the same information that
I previously put in the application configuration file.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="StrongLibrary"
publicKeyToken="6b5322bd2869c315"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0"
newVersion="1.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Then make a Publisher Policy Assembly. This is done using the assembly
linker tool.
al /link:publisherPolicyFile /out:publisherPolicyAssemblyFile
/keyfile:keyPairFile
In this command:
The publisherPolicyFile argument is the name of the publisher policy file.
The publisherPolicyAssemblyFile argument is the name of the publisher
policy assembly that results from this command. The assembly file name
must follow the format: policy.majorNumber.minorNumber.mainAssemblyName.dll
The keyPairFile argument is the name of the file containing the key
pair. You must sign the assembly and publisher policy assembly with the
same key pair.

The following is the command I used in my prototype.
al /link:policy.config /out:policy.1.0.StrongLibrary.dll
/keyfile:StrongLibrary.snk

You then use the gacutil to register the policy.
gacutil /I policy.1.0.StrongLibrary.dll
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top