Problem with Publisher Policy File (Can't install)

C

cpnet

I'm having problems with a publisher policy file I'm trying to put in the
GAC. I did it with a previous verison, but now I can't seem to get it to
work. The error I get is, "Failure adding assembly to the cache: One of
more modules specified in the manifest not found.". I am using gacutil to
try to install the policy file into the GAC.

The following works fine when I put it in the app config file:

<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyCompany.MyAssembly.NET"
publicKeyToken="db4fd244c1bc0b6e"
culture="neutral" />
<!-- Redirecting to version 0.1.0.1 of the assembly. -->
<bindingRedirect oldVersion="0.1.0.0"
newVersion="0.1.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>



However, when I put the above XML into policy.config and try to put it into,
"policy.0.1.MyCompany.MyAssembly.NET.dll" I can't install it into the gac.
Here's the command I'm using to create
"policy.0.1.MyCompany.MyAssembly.NET.dll":

"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\al.exe"
/link:"$(SolutionDir)MyProj\policy.config"
/out:"$(SolutionDir)MyProj\output\policy.0.1.MyCompany.MyAssembly.NET.dll"
/keyfile:"$(SolutionDir)StrongName\MyCompany.snk"

The strong name key file is the same one used to sign all of my assemblies.
I've tried with both the old an new versions of
"MyCompany.MyAssembly.NET.dll" in the GAC already (they install fine). I've
double checked the culture, versions, and the public key token.

Help!
 
C

cpnet

Looking at my "policy.0.1.MyCompany.MyAssembly.NET.dll" file, in ILDASM, the
only assembly it seems to reference is mscorlib.

When I look at the GAC viewer, I actually see there's 2 copies of mscorlib -
but they're exactly the SAME!!! (Same version, culture, name, public
key)?!? This shouldn't be happening should it? I also see that I seem to
have 4 identical copies of MS.VSDesigner in the GAC. This is on a fully
patched WinXP Pro sp2 machine.

I tried installing on my SBS 2k3 server, and I get the same error trying to
put "policy.0.1.MyCompany.MyAssembly.NET.dll" in the GAC. The GAC on the
SBS box doesn't seem to have duplicate assemblies, so maybe that's not the
problem.

But, I may have 2 separate problems: I can't install
"policy.0.1.MyCompany.MyAssembly.NET.dll" into the GAC, and the GAC on my XP
machine seems to have multiple copies of the same assembly.
 
B

Brock Allen

When I look at the GAC viewer, I actually see there's 2 copies of
mscorlib - but they're exactly the SAME!!! (Same version, culture,
name, public key)?!? This shouldn't be happening should it? I also
see that I seem to have 4 identical copies of MS.VSDesigner in the
GAC. This is on a fully patched WinXP Pro sp2 machine.

Some of those are ngen images, and even with those you can have a debug and
a release version. Also, how many versions of the CLR do you have installed?
That could account for the multiple copies.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
C

cpnet

This is sort of working now, but not in a satisfactory way. I found out the
problem was that I didn't have "policy.config" in the same folder as where,
"policy.0.1.MyCompany.MyAssembly.NET.dll", was located when I tried to add,
"policy.0.1.MyCompany.MyAssembly.NET.dll" to the GAC. As soon as
"policy.config" was in the right place, things seemed to work.

To try and avoid this problem, I tried to build
"policy.0.1.MyCompany.MyAssembly.NET.dll" with al.exe, using the "embed"
option instead of "link". This seemed to go ok, and I was able to install
"policy.0.1.MyCompany.MyAssembly.NET.dll" into the GAC without having to
worry about the location of "policy.config". So far, so good. However, I
found that my publisher policy file wouldn't function when it's created with
"embed" rather than "link".

So, now I'm confused. How would I distribute this? I don't know where
policy.config will be on the client machine, and putting
"policy.0.1.MyCompany.MyAssembly.NET.dll" in the GAC seems to lose most of
it's benifit if it has to know about some path to policy.config on the
client's machine. It doesn't seem safe to have an install script
dynamically create "policy.0.1.MyCompany.MyAssembly.NET.dll", since that
would require also shipping the private part of my key file to be able to
give a strong name to "policy.0.1.MyCompany.MyAssembly.NET.dll". Maybe I'm
missing something here, but if I can't embed policy.config into
"policy.0.1.MyCompany.MyAssembly.NET.dll", how can I be sure that
policy.config will be found?
 
C

cpnet

I think you're right. I need policy.config when adding
"policy.0.1.MyCompany.MyAssembly.NET.dll" into the GAC, but once
"policy.0.1.MyCompany.MyAssembly.NET.dll" is in the GAC, I can erase
policy.config, and everything works fine.

I didn't think something like policy.config could be added to the GAC. I
guess you just can't _directly_ add something like this to the GAC.

Thanks for your help Brock!
 
C

cpnet

I guess I need to brush up on my knowledge of assemblies and the GAC. I
thought that at least one of the properties I can see in the GAC viewer
(name, version, culture, public key etc). had to differ for multiple
versions of the 'same' assembly to be in the GAC. But I guess other things
can differ that aren't immediately visible.
 

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