在C#中为自己的项目创建自己的插件 [英] Creating my own plug-ins for my own project in C#

查看:90
本文介绍了在C#中为自己的项目创建自己的插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#开发一个项目,该项目是关于E-learning的.该项目应使用插件作为主要输入,没有插件就无法运行. 我不知道如何使用插件,对如何在程序中编译插件,或者如何在应用程序中安装插件一无所知. 我在这里问有关参考文献或任何有用的想法,可以帮助我解决这个问题.

I'm working on a project in C#, it's about E-learning.This project should use plug-ins as its main inputs, it can't function without them. I have no idea how can I work with plug-ins, I know nothing about how can a plug-in compile inside my program, or how can I install them inside my application. I'm asking here about references, or any useful ideas that can help me with this.

推荐答案

首先创建一个插件接口:

Start by creating a Plug-In Interface:

public interface IPlugIn
{
    // Your stuff here
}

然后您可以将界面分发给使用插件的开发人员.

You can then distribute your interface to the developers working on the plugins.

应用程序启动时,它可以动态加载所有插件程序集,然后通过IPlugIn界面使用它们,而无需了解每个插件程序的内部.

When your application starts up, it can load all Plug-In assemblies dynamically, then work with them through the IPlugIn interface without needing to know the internals of each one.

更新

我实际上找到了一篇文章,该文章更深入地介绍了我的过程,并提供了更多的例子.您可以在这里查看:

I actually found an article that goes into the process I described in more depth with more ellaborate examples. You can check it out here:

在.NET中编写基于插件的应用程序

还有一个额外的好处...它与代码示例一起提供!

And an added bonus...it comes with Code Samples!

这篇关于在C#中为自己的项目创建自己的插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆