Policy File Not Working?

D

DesperateDan

1/ Got two versions of the same DLL in the GAC called ClassForGac.dll;
V1.0.0.0 & V2.0.0.0 (No problem so far)
2/ Got client.EXE that was compiled against V1.0.0.0. and calls
V1.0.0.0 happily.
3/ Decided to point client.EXE to V2.0.0.0 so I created the policy file
as follows:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ClassForGac"
publicKeyToken="ac4d1fbd7d28b4c6" culture="neutral"/>
<bindingRedirect oldVersion="1.0.0.0-1.0.65535.65535"
newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

4/ After this I generate the policy file into a DLL
5/ Finally I publish the resulting DLL to the GAC

Question: Why does client.EXE still insist on calling V1.0.0.0

N.B. Same SNK file used throughout (publicKeyToken="ac4d1fbd7d28b4c6" )

Regards

Dan
 
A

Anthony Paul

Hello Dan,

Did you use AL properly to generate the dll policy file?

Al.exe /out:policy.1.0.ClassForGac.dll /version:1.0.0.0
/keyfile:DesperateDan.keys /linkresource:ClassForGac.config

And did you make sure that the generated policy file is installed in
the GAC?

Anthony
 
A

Anthony Paul

Hi Dan,

No problem, glad to help!

As for your problem, I belive you took MS a little too literally when
constructing the command line arguments. Try mine instead exactly as
written except of course replacing the DesperateDan.keys with your
strong name key filename instead and using your policy xml filename as
the config file. That should do it, and make sure to put it in the GAC.

Let me know how it went!

Anthony
 
A

Anthony Paul

DesperateDan said:
Anthony,
Firstly thanks for helping.

I used al /link:publisherPolicyFile.xml
/out:publisherPolicyAssemblyFile.DLL /keyfile:keyPairFile.SNK
As directed by MS site :
http://msdn.microsoft.com/library/d...ide/html/cpconcreatingpublisherpolicyfile.asp

I don't have a config file. Should I? In addition, I don't know what
the link parameter does (despite reading the help!)

Appreciate any response
Dan

To make this absolutely clear, try the following :

AL.exe /out:policy.1.0.ClassForGac.dll /version:1.0.0.0
/keyfile:DesperateDan.keys /linkresource:publisherPolicyFile.xml

Then publish the resulting dll in the GAC. You will still need to have
the publisherPolicyFile.xml file present when deploying your package
however, so for now make sure to have the xml file present in the same
folder as the main executable.

Also, the naming of the policy file is VERY important in the /out
portion. First, policy files MUST start with the word Policy, then the
major and minor versions of the assembly that you wish to redirect, and
then the name of the aforementioned assembly, all of which are period
delimited.

Cheers!

Anthony
 
D

DesperateDan

Sorry to persist this but still no joy.

here's what I did (exact command line):-

Al.exe /out:policy.1.0.ClassForGac.dll /version:1.0.0.0
/keyfile:70310.snk /linkresource:policy.ShouldBeIntheGac.xml

Where:
policy.ShouldBeIntheGac.xml - My xml file (see 1st posting)
70310.snk - The SNK file I've always used

Finally, successfully published the resulting DLL with
GACUTIL /i Policy.1.0.ClassForGac.dll

Result:
Caller still calls V1 of ClassForGac.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