private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         object obj = listBox1.SelectedItem;
         if (obj != null && (listBox1.SelectedIndex > 0 || listBox1.SelectedIndex < listBox1.Items.Count))
         {
             IPluginPlus ips = ((IPluginPlus)obj);
             try
             {
                 ips.Invoke(Global.env);
             }
             catch (NotImplementedException)
             {
                 bx[0] = false;
                 try
                 {
                     var result = ips.Invoke2(Global.env, out mi);
                     ips.DealReturnValue(this.listBox2, result);
                 }
                 catch (NotImplementedException)
                 {
                     bx[1] = false;
                     if (!bx[0] && !bx[1])
                     {
                         throw new MyException("两个方法都未实现,请检查!");
                     }
                 }
             }
             loglibrary.LogHelper.Info("returntype:" + mi.returntypoe.FullName.ToString());
             loglibrary.LogHelper.Flush();
         }
     }
     catch (Exception ec)
     {
         if (!(ec is MyException))
         {
             loglibrary.LogHelper.Error(ec);
             loglibrary.LogHelper.Flush();
         }
         else
         {
         }
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            List <string> pluginpath = helper.FindPlugin();

            pluginpath = helper.DeleteInvalidPlunginPlus(pluginpath);
            foreach (string filename in pluginpath)
            {
                try
                {
                    //获取文件名
                    string asmfile = filename;
                    string asmname = Path.GetFileNameWithoutExtension(asmfile);
                    if (asmname != string.Empty)
                    {
                        // 利用反射,构造DLL文件的实例
                        Assembly asm = Assembly.LoadFile(asmfile);
                        //利用反射,从程序集(DLL)中,提取类,并把此类实例化
                        Type[] t = asm.GetExportedTypes();
                        foreach (Type type in t)
                        {
                            if (type.GetInterface("IPluginPlus") != null)
                            {
                                IPluginPlus pluginitem = (IPluginPlus)Activator.CreateInstance(type);
                                listBox1.Items.Add(pluginitem);
                                listBox3.Items.AddRange(new[] { "name:" + pluginitem.GetName(), "Version:" + pluginitem.version() });
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    loglibrary.LogHelper.Error(ex);
                    loglibrary.LogHelper.Flush();
                }
            }
        }