将策略文件添加到 GAC 时出错

发布于 2024-07-09 07:09:16 字数 1665 浏览 9 评论 0原文

我正在尝试按照此 thread 但当我尝试在测试服务器上添加文件时遇到问题。

我收到“无法找到程序集 'policy.3.0. assemblyname.dll' 清单中指定的模块”

我的策略文件如下所示:

<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>

请帮忙!

谢谢

本,


我已经使用一个本身没有依赖项(除了默认值)的新程序集从头开始重新创建了问题 - 在我的本地开发计算机上一切正常(并且重定向也很好),但将策略文件添加到时会出现相同的错误服务器上的 GAC!

<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>

链接如下,

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

请帮忙!

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


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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夜唯美灬不弃 2024-07-16 07:09:16

哇 - 好的,明白了。

我应该更加注意这到底意味着什么

(MSDN) 如何:创建发布商政策

重要说明:发布商政策
程序集无法添加到全局
程序集缓存除非原始的
发布者策略文件位于
与程序集相同的目录。

坦率地说,这个要求太奇怪了,以至于没有被注意到。 当您添加策略程序集时,编译到我尝试添加到 gac 的程序集中的原始策略文件必须与策略程序集位于同一文件夹中。

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.

酒儿 2024-07-16 07:09:16

好的...只是想检查一些基础知识...

您肯定已经将两个版本的依赖程序集安装到 GAC 了吗?

并且您是否已验证 [程序集:AssemblyVersion()] 属性中的版本号是否正确。

并且您确实使用了[程序集:AssemblyVersion()]和NOT[程序集:AssemblyFileVersion("1.0.0.1")]。

更新:我的错误,您只需要GAC中最新版本的程序集。 我刚刚在这里尝试过,它有效。 我唯一的其他想法是检查公钥令牌是否相同并且您没有拼写错误程序集名称。

此外,当您生成策略文件时,请确保在程序集链接器中使用 /version 开关将版本号显式设置为 3.0.0.0 并且 不要指定 /platform 开关。 例如

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

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

You definitely have got both versions of the dependent 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 misspelled 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
樱花细雨 2024-07-16 07:09:16

要使用 Wise 将策略程序集添加到 GAC,您需要执行与添加策略所针对的程序集相同的操作。 因此,您将策略程序集添加到 Wise 中的“全局程序集缓存”中,只要您在计算机上的同一位置拥有策略文件 (.config),Wise 也会自动将其添加到 GAC 中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文