在動態引用DLL-A中,當參數是個實體,而實體的屬性在另一個DLL-B中。。我們需要得到A這個實體並將其賦值,並將賦值的實體傳人DLL-A的方法中。

來源:互聯網
上載者:User

標籤:

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

 

在動態引用DLL-A中,當參數是個實體,而實體的屬性在另一個DLL-B中。。我們需要得到A這個實體並將其賦值,並將賦值的實體傳人DLL-A的方法中。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.