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

Re: Policy File Not Working? by Anthony

Anthony
Thu Jan 11 09:09:57 CST 2007

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


Re: Policy File Not Working? by DesperateDan

DesperateDan
Thu Jan 11 09:54:28 CST 2007


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/default.asp?url=/library/en-us/cpguide/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


Re: Policy File Not Working? by Anthony

Anthony
Thu Jan 11 10:02:42 CST 2007

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


Re: Policy File Not Working? by Anthony

Anthony
Thu Jan 11 10:12:56 CST 2007


DesperateDan wrote:
> 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/default.asp?url=/library/en-us/cpguide/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


Re: Policy File Not Working? by DesperateDan

DesperateDan
Mon Jan 15 04:47:16 CST 2007

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


Re: Policy File Not Working? by Anthony

Anthony
Mon Jan 15 09:58:50 CST 2007

You seem to be doing everything right so I can't see why you're still
having this problem. You might want to read
http://www.ondotnet.com/pub/a/dotnet/2003/03/17/bindingpolicy.html and
learn how to do it on a system level. Perhaps it's overriding your
setttings?

Cheers!

Anthony

DesperateDan wrote:
> 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