C#插件系统设计
所以我正在为我的应用程序创建一个插件系统。
我有以下组件: 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想在编译解决方案时执行此操作,则应该创建一个构建后事件(项目属性 -> 构建事件)以仅将所需的文件复制到插件目录。
您还可以更改项目的 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.
当您编译插件项目时,右键单击您所看到的 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.
托管扩展性框架专为插件架构而设计。在你在当前的道路上走得太远之前,先检查一下。它可能会更好地为您服务。
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.