MEF 从不在执行程序集而是另一个 dll 的文件夹中加载插件(dll)。你能帮忙吗?
我需要实现一个非常小的插件架构。我是 MEF 新手,所以即使简单的事情也会变得复杂。 假设我有 2 个 dll 客户端(执行程序集)和服务器 在服务器中,我有一个名为“Plugins”的文件夹,
通常我在执行程序集的 bin 目录中创建一个“Plugins”文件夹,并且所有代码都适用于这段代码,如果插件文件夹位于服务器中,如何使其工作?
private void LoadPlugins(string folder)
{
AggregateCatalog catalog=new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
catalog.Catalogs.Add(new DirectoryCatalog(folder));
CompositionContainer container =new CompositionContainer(catalog);
container.ComposeParts(this);
}
有什么建议吗?
聚苯乙烯 这些插件仅用于处理服务器内的逻辑,客户端根本不使用它们
I need to implement a very small plugin architecture.I am new to MEF so even simple things become complex.
Lets assume I have 2 dlls Client(Executing Assembly) and Server
Within Server I have a folder called "Plugins"
Usually I create a "Plugins" folder in the bin directory of the executingAssembly and all works with this piece of code,How Can I make it work if the plugin folder is in the Server?
private void LoadPlugins(string folder)
{
AggregateCatalog catalog=new AggregateCatalog();
catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
catalog.Catalogs.Add(new DirectoryCatalog(folder));
CompositionContainer container =new CompositionContainer(catalog);
container.ComposeParts(this);
}
Any Suggestions?
PS
The plugins will only be used to process logic within the server they are not used at all by the client
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想从服务器下载插件并在客户端应用程序中使用它们吗?如果是这样,您可以将它们下载到特定路径并通过该路径创建目录。或者,您可以下载每个程序集,使用 Assembly.Load() 或类似方法加载它,并在其上创建一个 AssemblyCatalog。
Do you want to download the plugins from the server and use them in your client app? If so, you could download them to a specific path and create the catalog over that path. Or you could download each assembly, load it with Assembly.Load() or a similar method, and create an AssemblyCatalog over it.