C#插件系统设计

发布于 2024-09-29 07:49:01 字数 298 浏览 4 评论 0原文

所以我正在为我的应用程序创建一个插件系统。

我有以下组件: 1) 主要用途 2)插件接口.dll 3) Plugin(s).dll

现在的问题是,当我创建插件并编译它们时,除了 Plugin.dll 文件之外还有更多文件。它在 Release 目录中还有其他必需的文件,例如它使用的 PluginInterface.dll、xml 配置文件等。

那么我怎样才能使其成为用户可以放入插件目录的单个 dll 文件呢?

或者

您认为将插件放在文件夹中更好?然后,我必须扫描所有文件夹以查找正确的 DLL...

So I am creating a plugin system for my app.

I have the following components:
1) Main Application
2) PluginInterface.dll
3) Plugin(s).dll

The problem now is that, when I create my plugins and compile them, there are more then just the Plugin.dll file. It has other required files in the Release directory such as the PluginInterface.dll that it uses, an xml configuration file, etc.

So how can I make it so that it is just a single dll file that user can drop into a plugin directory?

OR

do you think it's better to have the plugins be a folder? then, i have to scan all the folders for the right DLL...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷雾森÷林ヴ 2024-10-06 07:49:05

如果您想在编译解决方案时执行此操作,则应该创建一个构建后事件(项目属性 -> 构建事件)以仅将所需的文件复制到插件目录。
您还可以更改项目的 OutputPath 并使用选项“Copy Local”为“false”,但您将无法获得与创建构建事件相同级别的控制权。

If you want to do that when compiling your solution you should create a post build event (Project Properties -> Build Events) to copy only the required files to the plugin directory.
You could also change the OutputPath of you project and use the option "Copy Local" to "false", but you'll not have the same level of control as by creating a build event.

指尖微凉心微凉 2024-10-06 07:49:04

当您编译插件项目时,右键单击您所看到的 DLL 的引用并选择属性。在属性中将“Copy Local”属性设置为“false”。确保这些 DLL 是主应用程序的一部分,否则当找不到依赖于它的代码时,代码将会失败。

When you compile your plug-in project, right-click on the references to the DLLs you are seeing and select properties. In the proepties set the "Copy Local" property to "false". Make sure that these DLLs are part of your main application, otherwise the code will fail when it can't find code that depends on it.

吃兔兔 2024-10-06 07:49:03

托管扩展性框架专为插件架构而设计。在你在当前的道路上走得太远之前,先检查一下。它可能会更好地为您服务。

The Managed Extensibility Framework is designed for plugin architectures. Before you go too far down your current path, check it out. It might serve you better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文