gds通用软件开发系统

导航

c#内存中创建反射

代码

  IWFP_SYS_Bytes mywfpbyte;
                             
                            /**/
                            byte[] bin=null;
                            using (FileStream fs = new FileStream(filename, FileMode.Open))
                            {
                                BinaryReader br = new BinaryReader(fs);
                                 bin = br.ReadBytes(Convert.ToInt32(fs.Length));
                                fs.Close();
                                br.Close();
                            }
                            Assembly vAssembly = Assembly.Load(bin);// Assembly.LoadFrom(filename);
                             
                            System.Globalization.CultureInfo gcnull = null; 
                            object[] objnull = null;
                            Binder binull = null;
                            object vTemp = null;
                            object[] objParm = null;//传递的参数
                            AppDomain ad = AppDomain.CreateDomain("DLL Unload test");

                            vTemp = vAssembly.CreateInstance(Classname, true, BindingFlags.Default, binull, objParm, gcnull, objnull);
                            if (vTemp != null)
                            {
                                mywfpbyte = (IWFP_SYS_Bytes)vTemp;
                                mywfpbyte.DBtype = ConfigurationManager.AppSettings["DBtype"];
                                mywfpbyte.PSQL = ConfigurationManager.AppSettings["PSQL"];
                                mywfpbyte.WFPCon = WFPCon;
                                isrun = 1;
                               
                                byte[] rebytes= mywfpbyte.WFP_SYS_BytesSQL(args, Param, mpath, myurl, out errorInfo);
                                   
                                AppDomain.Unload(ad);
                                mywfpbyte = null;

                                return rebytes;
                            }

 

posted on 2013-11-26 11:45  gds通用软件开发系统  阅读(3525)  评论(0编辑  收藏  举报