zoukankan      html  css  js  c++  java
  • 在动态引用DLL-A中,当参数是个实体,而实体的属性在另一个DLL-B中。。我们需要得到A这个实体并将其赋值,并将赋值的实体传人DLL-A的方法中。

      string strPath = HttpContext.Current.Server.MapPath("/开放式DLL");
                    DirectoryInfo df = new DirectoryInfo(strPath);
                    System.IO.FileInfo[] fr = df.GetFiles();
                        foreach (System.IO.FileInfo f in fr)
                    {
                        if (f.Name.EndsWith("CNKI_Mngr.dll"))
                        {
                            System.Reflection.Assembly Mngrass = System.Reflection.Assembly.LoadFrom(f.FullName);//加载程序集
    
                            Type cnkiStructtp = Mngrass.GetType("CNKI_Mngr.UserStruct");//获取程序集中的实体对象
                            Type cnkiBasetp = Mngrass.GetType("CNKI_Mngr.UserBaseInfo");
                            Type cnkiComtp = Mngrass.GetType("CNKI_Mngr.UserComInfo");
                            object obj1 = System.Activator.CreateInstance(cnkiStructtp);//创建实例
                            object obj2 = System.Activator.CreateInstance(cnkiBasetp);
                            object obj3 = System.Activator.CreateInstance(cnkiComtp);
                            FieldInfo[] BaseInfo = cnkiBasetp.GetFields();//获取创建的实例的所有属性
                            FieldInfo[] ComInfo = cnkiComtp.GetFields();
                            FieldInfo[] StructInfo = cnkiStructtp.GetFields();
    
                            BaseInfo[1].SetValue(obj2, enty.UserName);//对指定的属性就行赋值
                            BaseInfo[11].SetValue(obj2, enty.RealName);
                            BaseInfo[5].SetValue(obj2, enty.PassWord);
                            BaseInfo[13].SetValue(obj2, enty.Department);
    
                            ComInfo[2].SetValue(obj3, enty.EMail);
                            ComInfo[9].SetValue(obj3, enty.Phone);
    
                            StructInfo[0].SetValue(obj1, obj2);
                            StructInfo[1].SetValue(obj1, obj3);
    
                            foreach (System.IO.FileInfo item in fr)
                            {
                                if (item.Name.EndsWith("Grid30Register.dll"))
                                {
                                    System.Reflection.Assembly ass = System.Reflection.Assembly.LoadFrom(item.FullName);
                                    Type tp = ass.GetType("Grid30Register.CreateOperateClass");
                                    MethodInfo meth = tp.GetMethod("PersonLibRegister");
                                    object obj = System.Activator.CreateInstance(tp, new object[] { GridConfig.UserServerIP, GridConfig.UserServerIP, GridConfig.UserServerIP, 
                                    KbaseConfig.ServerIP, KbaseConfig.ServerUserName, KbaseConfig.ServerPsw, "", GridConfig.Language });
                                    ReStr = meth.Invoke(obj, new object[] { us }).ToString();
                                }
                            }
    
                        }
  • 相关阅读:
    VxWorks固件分析方法总结
    WebGoat系列实验Injection Flaws
    WebGoat系列实验Cross-Site Scripting (XSS)
    WebGoat系列实验Denial of Service & Insecure Communication
    WebGoat系列实验Buffer Overflows & Code Quality & Concurrency
    WebGoat系列实验Authentication Flaws
    WebGoat系列实验Access Control Flaws
    20155224 聂小益 《基于Arm实验箱的接口测试和应用》 课程设计报告
    实验补交的链接
    2017-2018-2 20155224『网络对抗技术』Exp4:恶意代码分析
  • 原文地址:https://www.cnblogs.com/SamllBaby/p/4771077.html
Copyright © 2011-2022 走看看