gpt4 book ai didi

c# - .Net 发布者政策——原始发布者政策文件?

转载 作者:太空宇宙 更新时间:2023-11-03 11:25:29 25 4
gpt4 key购买 nike

我正在检查我们是否应该为我们的解决方案创建发布者策略文件。为此我研究了MSDN documentation为主题。我对该页面上的最后一句话感到困惑(请注意,我指的是 .Net 3.5 版本,该句子可能不会出现在其他版本的文档中):

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.

i) “原始发布者政策文件”是什么意思?我们正在处理的场景是我们向客户发送了一个版本的解决方案(目前还没有发布者政策)。客户可能已经自己创建了程序集,这些程序集引用了我们的一些强命名程序集。现在我们的解决方案的新版本(更新)即将发布,这应该不会破坏客户组件。我的理解是发布者政策允许这样做,但我们会(可能)只在更新时发布它。这是个问题吗?

ii) 该句子中的最后一个词指的是哪个组件?包含发布者策略的程序集,或发布者策略为其定义绑定(bind)重定向的程序集?

iii) 文档说发布者政策必须添加到 GAC,但它没有说明任何有关受发布者政策影响的强命名程序集的信息。现在,对于我们的解决方案,这些被部署到应用程序目录中,我们希望保持这种状态。我对这个概念的理解是这是可能的。有人可以证实这一点吗?

蒂亚,

托马斯

最佳答案

what is meant by 'the original publisher policy file'?

这是您开发文件夹中的配置文件,例如1.0.MySharedAssembly.dll.config 必须位于与策略程序集本身相同的目录中,例如policy.1.0.MySharedAssembly.dll,然后将其添加到 GAC。

which assembly does the last word in that sentence refer to? The assembly containing the publisher policy, or the assembly for which the publisher policy defines the binding redirection?

这是发布者策略定义绑定(bind)重定向的程序集,例如:policy.1.0.MySharedAssembly.dll

你的第三个问题:是的,这个概念是可能的。您不必将共享程序集添加到 GAC 即可使发布者政策生效。只要您的程序集是强类型的,发布者策略就会将其从使用旧版本构建的客户端重定向到新版本的程序集。

我通常创建包含重定向的 1.0.MySharedAssembly.dll.config 文件(例如从 v1.0->v2.0 重定向),例如:

<assemblyIdentity name="MySharedAssembly"
publicKeyToken="2752785e627d5953"
culture="neutral" />
<!-- Redirecting to version 2.0.0.0 of the assembly. -->
<bindingRedirect oldVersion="1.0.0.0"
newVersion="2.0.0.0"/>

将其添加到我的项目中并吐出到目标目录中。然后创建 policy.1.0.MyAssemblyToRedirect.dll(定义绑定(bind)重定向),您可以使用 the assembly linker tool .我通常为我的 MySharedAssembly 项目使用构建后事件,例如:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\al.exe" /link:"$(TargetDir)1.0.MySharedAssembly.dll.config" /out:"policy.1.0.MySharedAssembly.dll" /keyfile:"$(ProjectDir)MySharedAssembly.snk"

然后,您在第二次构建后事件中注册到 GAC,例如:

"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\gacutil.exe" /i "$(TargetDir)policy.1.0.MySharedAssembly.dll" /f

关于c# - .Net 发布者政策——原始发布者政策文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9514556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com