views:

899

answers:

7

Hi all I'm trying to add a publisher policy file to the gac as per this thread but I'm having problems when I try and add the file on my test server.

I get "A module specified in the manifest of assembly 'policy.3.0.assemblyname.dll' could not be found"

My policy file looks like this:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="*assemblyname*"
                          publicKeyToken="7a19eec6f55e2f84"
                          culture="neutral" />
        <bindingRedirect oldVersion="3.0.0.0"
                         newVersion="3.0.0.1"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Please help!

Thanks

Ben

+1  A: 

Hi Ben,

Ok...just want to check some basics....

You definitely have got both versions of the dependant assembly installed to GAC?

And have you verified that the version numbers in the [assembly: AssemblyVersion()] attribute are correct.

And you did use [assembly: AssemblyVersion()] and NOT [assembly: AssemblyFileVersion("1.0.0.1")].

Update: My mistake, you only need the latest version of the assembly in the GAC. I just tried that here and it works. My only other thoughts are to check that the public key tokens are the same and that you've not mispelled the assembly name.

Also when you generate the policy file make sure you use the /version switch in the assembly linker to explicitly set the version number to 3.0.0.0 AND don't specify the /platform switch. e.g.

al.exe /link:assembly.config /out:policy.3.0.assembly.dll 
         /keyfile:mykey.snk /version:3.0.0.0

Cheers
Kev

Kev
A: 

Hi Kev - thanks for replying No I've only got the target version of the assembly in the GAC (3.0.0.1) - but this works on my dev machine (well it installs to the GAC, not sure if it redirects ok yet). Do I have to have the non-used version in the GAC if I want to do this redirect?

Assembly version and Assembly File version are both set to 3.0.0.1

Ben
Actually it seems you only need the latest version of the assembly in the GAC, so apologies for that red herring.
Kev
I added some more comments to my answer.
Kev
no worries, cool thanks
Ben
A: 

I wasn't supplying the version before and was specifying the /platform switch - however I made the change to the linker command and its still the same problem :(

I'm now calling it like this

copy PublisherPolicy.xml ..\bin\Release
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\al.exe /link:..\bin\Release\PublisherPolicy.xml /out:..\bin\Release\policy.3.0.*assemblyname*.dll /keyfile:..\..\key.snk /version:3.0.0.0
pause

It still installs on my dev box - it must be something to do with the environment on the test server but I've no idea what it is. What's it looking for - what does it want to resolve?

Ben
A: 

I've recreated the problem from scratch with a new assembly that has no dependancies (apart from the defaults) itself - all works fine on my local development machine (and redirects fine too) but gives the same error adding the policy file to the GAC on the server!

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="TestAsm"
                          publicKeyToken="5f55456fdcc9b528"
                          culture="neutral" />
        <bindingRedirect oldVersion="3.0.0.0"
                         newVersion="3.0.0.1"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

linked in the following way

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\al.exe /link:PublisherPolicy.xml /out:policy.3.0.TestAsm.dll /keyfile:..\..\key.snk /version:3.0.0.0
pause

Please help!

Ben
A: 

Wow - ok got it.

I should have paid more attention to exactly what this meant

(MSDN) How to: Create a Publisher Policy

Important Note: The publisher policy assembly cannot be added to the global assembly cache unless the original publisher policy file is located in the same directory as the assembly .

That requirement is, frankly, so bizarre that it didn't register. The original policy file, that was compiled into the assembly i'm trying to add to the gac, has to be in the same folder as the policy assembly as you add the policy assembly.

Ben
A: 

How do you add it to the GAC if you were installing the app using Wise?

micheal
A: 

To add policy assemblies to the GAC using Wise, you do the same thing as you do to add the assembly the policy is for. So you add the policy assembly to the "Global Assembly Cache" in Wise, and as long as you have the policy file (.config) in the same location on the machine, Wise will automatically add it to GAC as well.

related questions