加载dll
private void btn_LoadDll_Click(object sender, EventArgs e) { pnl_plugins.Controls.Clear(); string pluginPath = Application.StartupPath + @"\Plugins\"; if (!System.IO.File.Exists(pluginPath + "Plugin.dll")) { MessageBox.Show("没有匹配的插件","提示",MessageBoxButtons.OK,MessageBoxIcon.Information); return; } string data = "Plugin.Part"; try { // 加载控件 System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(pluginPath + "Plugin.dll"); // 获得类(型) Type type = assembly.GetType(data, false, true); Object obj = Activator.CreateInstance(type); System.Windows.Forms.Control control = obj as Control; pnl_plugins.Controls.Add(control); } catch { MessageBox.Show("插件加载失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }