zoukankan      html  css  js  c++  java
  • 加载dll

    加载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);
                }
            }
  • 相关阅读:
    JSP第二次作业
    软件测试课堂练习
    内容提供者读取短信信息
    购物车
    第六周jsp
    第四周jsp
    第一周 软件测试
    第八次安卓
    安卓第七次作业
    安卓第六次作业
  • 原文地址:https://www.cnblogs.com/cmblogs/p/2850144.html
Copyright © 2011-2022 走看看