简体   繁体   English

弱装配改为强装配

[英]Weak assembly changed to strong assembly

I have a plugin structure which all is compiled using weak assemblies. 我有一个使用弱程序集编译的插件结构。 I want to change this now but running into some difficulties. 我现在想更改此设置,但遇到一些困难。

interface.dll contains my interface for my plugins (IPlugin)
Load.exe will load all the plugin implementations which implements IPlugin
pluginA.dll contains a implementation of IPlugin

All assemblies is original weak assemblies. 所有程序集都是原始的弱程序集。

I now want to change the assemblies to strong name assemblies. 我现在想将程序集更改为强名称程序集。

After I have made the interface.dll and load.exe strong name assemblies I am unable to create an instance of the pluginA.dll IPlugin implementation, unless I have recompiled pluginA.dll to reference the new strong name interface.dll 制作好interface.dll和load.exe强名称程序集后,除非重新编译pluginA.dll以引用新的强名称interface.dll,否则无法创建pluginA.dll IPlugin实现的实例。

Is there a way for me to set strong name on interface.dll and load.exe without being forced to recompile all plugins implementing IPlugin? 有没有办法让我在interface.dll和load.exe上设置强名称,而不必强迫重新编译实现IPlugin的所有插件?

The reason I ask this, is that I have a lot of plugins and I don't have control of all of them. 我之所以这样问,是因为我有很多插件,而我却无法控制所有插件。 So I want to avoid breaking the plugin functionallity when I updated the interface.dll with a strong name. 因此,当我使用强名称更新interface.dll时,我想避免破坏插件的功能。

I hope you can help me, and please do not hesitate to ask for further details if something is unclear. 希望您能为我提供帮助,如果有不清楚的地方,请随时询问更多详细信息。

Thanks 谢谢

Giving an assembly a strong name is a hard breaking change. 给大会一个好名字是一项艰巨的改变。 You cannot patch it up with a config file or publisher policy. 您无法使用配置文件或发布者策略对其进行修补。 So rebuilding the plug-ins is a hard requirement you cannot skip. 因此,重建插件是一项艰巨的要求,您不能跳过。

You didn't otherwise state the reason for deciding to do so. 否则,您没有说明决定这样做的原因。 There is no compelling one in a plug-in scenario. 在插件方案中没有引人注目的。 A strong name provides a way to verify that an assembly is an exact match with the reference assembly that your program was built with. 强名提供了一种方法来验证程序集与构建程序的参考程序集是否完全匹配。 But, by design, you don't have a reference assembly for a plug-in. 但是,在设计上,你没有一个插件参考组装。 So there's nothing to verify. 因此,没有什么可验证的。

There is no way around this, unfortunately. 不幸的是,这没有办法。 The benefits you derive from strong-naming an assembly (most likely the reasons you are converting yours) are lost if you can reference simple named assemblies. 如果可以引用简单的命名程序集,则从对程序集进行强命名中获得的好处(很可能是您转换程序集的原因)将丢失。

From Microsoft's documentation : 从Microsoft的文档中

When you reference a strong-named assembly, you expect to get certain benefits, such as versioning and naming protection. 引用强名称程序集时,您期望获得某些好处,例如版本控制和命名保护。 If the strong-named assembly then references an assembly with a simple name, which does not have these benefits, you lose the benefits you would derive from using a strong-named assembly and revert to DLL conflicts. 如果强命名程序集引用了一个没有这些优点的简单名称的程序集,则您将失去使用强命名程序集所带来的好处,并转换为DLL冲突。 Therefore, strong-named assemblies can only reference other strong-named assemblies. 因此,强名称程序集只能引用其他强名称程序集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM