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;
                            }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM