[英].Net Add-ins and versioning
Our media center add-in is shipped as a single DLL which lives in the GAC (mediabrowser.dll), we allow users to write extensions for our add-in by referencing our DLL and accessing the pre-defined extensibility points. 我们的媒体中心加载项作为单个DLL提供,它存在于GAC(mediabrowser.dll)中,我们允许用户通过引用我们的DLL并访问预定义的扩展点来为我们的加载项编写扩展。
On load we search through a plug-in directory, load all the assemblies in the directory, search the assemblies for a type implementing IPlugin and execute initialiaztion routine on an instance of the plugin. 在加载时,我们搜索插件目录,加载目录中的所有程序集,在程序集中搜索实现IPlugin的类型,并在插件的实例上执行initialiaztion例程。 I am aware that this is not the most robust design (for example: we may want to look at appdomain isolation for plugin later on) but it works alright now. 我知道这不是最强大的设计(例如:我们可能希望稍后查看appdomain隔离插件),但它现在可以正常工作。
As it stands, this seems to be working fine, except for one big caveat. 目前看来,这似乎工作得很好,除了一个很大的警告。
When plugin writers compile their plugins the plugin references mediabrowser.dll with a specific version. 当插件编写者编译他们的插件时,插件引用了具有特定版本的mediabrowser.dll。 Later on when we revise our dll (to fix bugs or add features) all addins that were written against earlier versions of mediabrowser.dll break. 稍后当我们修改我们的dll(修复bug或添加功能)时,所有针对mediabrowser.dll早期版本写入的插件都会中断。
I have thought of a few solutions to this problem (note the assembly is in the GAC): 我已经想到了这个问题的一些解决方案(请注意程序集在GAC中):
Are there any other solutions to this problem that I am missing? 我错过了这个问题的其他解决方案吗?
Update I ended up going with option 4. 更新我最终选择了4。
I see you have picked an answer but if you are still open to ideas there is another option to consider (the very one used by the .NET framework): do not increment your assembly version between builds (but do increment your assembly build number). 我看到你已经选择了一个答案,但是如果你仍然对想法持开放态度还有另外一个选择(.NET框架使用的那个):不要在构建之间增加程序集版本(但是增加你的程序集内部版本号) 。
This will allow your assembly to retain it's same strong name, not breaking plugin compat, and still allow you to distinguish builds from each other (using the assembly build number). 这将允许您的程序集保留其相同的强名称,而不是破坏插件compat,并且仍允许您区分构建(使用程序集内部版本号)。
You can see this in action in .NET 2.0 through 3.5. 您可以在.NET 2.0到3.5中看到这一点。 Those releases all use the assembly version 2.0.50727 but have distinct build versions. 这些版本都使用程序集版本2.0.50727,但具有不同的构建版本。
As long as you do not break your interface contracts (which you should never do anyway) this approach is quite reasonable. 只要你不破坏你的界面合同(你永远不应该这样做),这种方法是非常合理的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.