使用 Silverlight / MEF 加载同一插件的 2 个版本
我的场景是经典的 MEF 场景。有一个 silverlight 主机应用程序,该应用程序可以动态下载插件以添加功能。插件可以由第三方创建。
现在,当不同的插件和/或主机应用程序引用同一程序集的不同版本时,就会出现问题。
例如:
-插件 A 引用 silverlight 工具包 dll 的 1.0 版,插件 B 引用同一 dll 的 2.0 版。
OR
-host app 引用反应式扩展 dll 的 1.0 版,而插件 C 引用同一 dll 的 2.0 版。
这是一个极有可能发生的问题。 插件和主机都是独立的,但考虑到这个问题,我意识到给定的插件可以工作一段时间,然后我更新主机应用程序的引用,或者添加一个新插件,导致另一个插件休息。
我对 Silverlight 程序集加载进行了一些研究,我相信一次只能加载给定程序集的一个版本。 因此我不知道如何处理这个问题。
对此有什么想法吗?
My scenario is a classic MEF scenario. There is a silverlight host app, and the app can download plugins on the fly to add functionality. Plug ins can be created by third parties.
Now the problem arises when different plugins and/or the host app reference different versions of the same assembly.
For example:
-plugin A references the version 1.0 of the silverlight toolkit dll and plugin B references the version 2.0 of the same dll.
OR
-host app references the version 1.0 of the reactive extensions dll and plugin C refernces the version 2.0 of the same dll.
That is a problem that is extremely likely to happen.
Plugins and the host are all meant to be independent but with this problem in mind, I realise that a given plugin could work for a while, and then I update a reference of the host app, or add a new plugin, causing another plugin to break.
I've done some research on Silverlight Assembly loading and I believe that only one version of a given assembly can be loaded at a time.
Therefore I don't know how to handle this.
Any ideas on that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想确保其正常工作,您将需要对应用程序可以下载哪些插件进行一些控制,并确保它们能够协同工作。
如果您有两个引用同一程序集的不同版本的插件,只要程序集中没有任何重大更改,您就可以让它们都工作。您需要确保首先加载更新版本的程序集,然后 Silverlight 还将其用于引用旧版本程序集的插件(请注意,此加载程序行为与桌面上的工作方式有很大不同) 。网)。
如果引用的程序集的不同版本中存在重大更改,那么您将无法使这两个插件正常工作。
You will need to exercise some control over what plugins the application can download and ensure that they work together if you want to ensure that this works.
If you have two plugins that reference different versions of the same assembly, you can get them both to work as long as there aren't any breaking changes in the assembly. You need to make sure that the more recent version of the assembly is loaded first, and then Silverlight will also use it for the plugin which references the older version of the assembly (note that this loader behavior is much different than how it works on desktop .NET).
If there are breaking changes in the different versions of the referenced assembly, then you won't be able to get both plugins to work.