在.NET中创建插件环境的最佳方法 [英] Best way to create a plugin environment in .NET

查看:166
本文介绍了在.NET中创建插件环境的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过这篇论文如何在.NET中加载插件?,我真的没有看到微软的System.Addin命名空间的光彩。为什么我不能在我的bin目录中有一个plugins文件夹,用户可以将程序集放入实现我设计的接口?然后,我可以使用反射来创建插件类的实例并使用我的界面引用它。

I read this aricle How to load plugins in .NET?, and I really don't see the brilliance of Microsoft's System.Addin namespace. Why can't I just have a plugins folder in my bin directory that users can put an assembly into that implements an interface I design? I could then just use reflection to create an instance of the plugin class and reference it with my interface.

为什么System.Addin显然要好得多?特别是因为它似乎是工作的三倍和不太直观的设计。

Why is the System.Addin way apparently so much better? Especially since it seems like three times the work and a less intuitive design.

推荐答案

好多了总是取决于你的观点的观点和要求。如果您的方法符合您的需求,那就去吧。但是插件变得非常复杂得多。插件之间的依赖关系怎么样?安全?不同的schemata如何找到插件? ...?这些功能已经为您解决了。如果您不需要它们,那么库可能会过度。如果你需要它们,重新发明轮子是个坏主意。 ; - )

"so much better" always depends on your point of view and requirements. If your approach fits your needs, go for it. But plugins can become very fast much more complicated. What about dependencies between plugins? Security? Different schemata how to find plugins? ...? Those kind of features are already solved for you. If you don't need them, a library might be overkill. If you need them, it would be a bad idea to reinvent the wheel. ;-)

这篇关于在.NET中创建插件环境的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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