C#DLL的插件架构 [英] C# DLL's plugin-architecture

查看:208
本文介绍了C#DLL的插件架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个程序,我开发使用基本的插件架构。实际上,当程序加载时,它使用反射来搜索适合某个接口的dll的目录,然后加载它们。
现在看来,目前的插件列表都是将被使用的。



因此,我目前的做法是检查dll文件仍然是最佳做法或者有更好的方式加载每个dll?



谢谢。

解决方案

你的问题看起来像你已经建立(或正在尝试构建)您自己的插件架构。它不是一个好主意,因为.NET已经有你想要的东西。



.NET有两种方式允许插件。


  1. System.Addin

  2. MEF - 管理可扩展性框架

(1) System.Addin - 我几乎听不到/读了很多。但是您可以在这里查看几篇文章:

MSDN杂志的System.Addin文章 - 请注意2007年年度

系统.Addin工具和示例在Codeplex



(2)现在,MEF,MEF是真棒!它是将插件架构引入到系统中的一种非常简单的方式。 MEF也是Silverlight的一部分,Visual Studio 2010使用它。我可以看到你想要动态加载DLL插件,使用MEF,您可以按照这样的方式设计您的应用程序,使用您的软件打包的类可以在自己的程序集(.exe)中,然后可以使用MEF动态查找dll在将来会有你需要的课程。整个过程本身在MEF中非常简单。



Mike Taulty在MEF上有一个辉煌的视频系列



Codeproject上的MEF文章 - 第1部分
Codeproject上的MEF文章 - 第2部分



MEF是Codeplex上的开源软件


$ b $我个人认为,你应该去MEF,它的新的,容易,甚至可视化的工作室使用它,即使这样你可以看一下:

在MEF和MAF之间进行选择(System.AddIn )



做检查在SO上的其他热门投票问题在mef标签


I have a program that i developed to use a basic plugin architecture. Effectively, when the program loads it uses reflection to search the directory for dll's that fit a certain interface and then loads them. It now appears that the current list of plugins is all that will be used.

Therefore, is my current practise of check the dll files still the best practise, or are there better ways to load each dll?

Thanks.

解决方案

From your question it looks like you've built (or are trying to build) your own kind of plugin architecture. Its not such a good idea since .NET already has what you're looking for.

.NET comes with 2 ways to allow plugins.

  1. System.Addin
  2. MEF - Managed Extensibility Framework

(1) System.Addin - I've barely heard/read much about it. But you can take a look at a few articles here:
System.Addin article from MSDN magazine <- Note the Year 2007
System.Addin tools and examples at Codeplex

(2) Now, MEF, MEF is just awesome! Its a great and easy way to introduce a plugin architecture into your system. MEF is also a part of Silverlight and Visual Studio 2010 uses it. I can see you want to load dlls with plugins dynamically, with MEF you can design your app in such a way the classes you package with your software can be in your own assembly (.exe) and then you can use MEF to dynamically look for dlls in the future that will have classes that you need. The whole procedure itself is very simple in MEF.

Mike Taulty has a brilliant video series on MEF

MEF Article at Codeproject - Part 1 MEF Article at Codeproject - Part 2

MEF is Open Source on Codeplex

I personally think you should go with MEF, its new, easy and even visual studio uses it, even so you can take a look at:
Choosing between MEF and MAF (System.AddIn)

Do check out other top voted questions on the mef tag at SO

这篇关于C#DLL的插件架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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