方法:加载dll,再界面创建控件,注册控件的点击事件
namespace WindowsFormsApplication2
{
public partial class Form1 :Form
{
public Form1()
{
InitializeComponent();
Type[] typePublic = null; Type typeIExecute = null;
string exeDirPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); //得到运行目录
string[] dellPaths = Directory.GetFiles(exeDirPath, "*.dll");
for (int i = 0; i < dellPaths.Length; i++)
{
Assembly asm = Assembly.LoadFile(dellPaths[i]);
//Assembly asm = Assembly.LoadFrom("ClassLibrary1.dll");
typePublic = asm.GetExportedTypes();//得到所有的public方法