c# - .Net 发行商策略——原始发行商策略文件?

标签 c# .net versioning

我正在检查是否应该为我们的解决方案创建发布者策略文件。为此我研究了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/

相关文章:

c# - 无法在 C# 中将临时文档上传到 Adob​​e Sign

.net - 分机JS 4 : Rich Text or HTML Text Editor in Sencha Ext JS Framework

java - 如何在多模块 Maven 项目设置中为所有子级设置不同版本

c# - 如何在 Visual Studio 2022 中使用日期/时间更改 AssemblyInfo.cs AssemblyVersion 并每天将修订增加一

c# - 如何获取内联委托(delegate)的参数?

c# - 使用泛型 C# 反序列化动态 XML

c# - Microsoft.WindowsAPICodePack.Shell音频持续时间未获得

c# - LINQ 查询未检索保存的数据

c# - 是否可以将多个通用类型参数传递给一个方法?

version-control - 在 Windows 中安装 SCM Manager(Mercurial 管理 Web 前端)