In dynamic reference dll-a, when the argument is an entity, and the entity's properties are in another dll-b: We need to get the entity of a and assign it and assign the entity to the Dll-a method.

Source: Internet
Author: User

  stringstrpath = HttpContext.Current.Server.MapPath ("/Open DLL"); DirectoryInfo DF=NewDirectoryInfo (strpath); System.io.fileinfo[] FR=DF.                    GetFiles (); foreach(System.IO.FileInfo Finchfr) {                    if(F.name.endswith ("Cnki_mngr.dll") {System.Reflection.Assembly Mngrass= System.Reflection.Assembly.LoadFrom (F.fullname);//Loading AssembliesType cnkistructtp= Mngrass.gettype ("cnki_mngr.userstruct");//get entity objects in an assemblyType CNKIBASETP = Mngrass.gettype ("Cnki_mngr.userbaseinfo"); Type CNKICOMTP= Mngrass.gettype ("Cnki_mngr.usercominfo"); ObjectObj1 = System.Activator.CreateInstance (cnkistructtp);//Create an instance                        ObjectObj2 =System.Activator.CreateInstance (CNKIBASETP); ObjectObj3 =System.Activator.CreateInstance (CNKICOMTP); Fieldinfo[] Baseinfo= Cnkibasetp.getfields ();//get all properties of the created instancefieldinfo[] ComInfo =Cnkicomtp.getfields (); Fieldinfo[] Structinfo=Cnkistructtp.getfields (); baseinfo[1]. SetValue (Obj2, Enty. UserName);//assigns a value to the specified property on the linebaseinfo[ One]. SetValue (Obj2, Enty.                        Realname); baseinfo[5]. SetValue (Obj2, Enty.                        PassWord); baseinfo[ -]. 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 Iteminchfr) {                            if(item. Name.endswith ("Grid30Register.dll") {System.Reflection.Assembly )=System.Reflection.Assembly.LoadFrom (item.                                FullName); Type TP= The. GetType ("Grid30register.createoperateclass"); MethodInfo Meth= TP. GetMethod ("Personlibregister"); Objectobj = System.Activator.CreateInstance (TP,New Object[] {gridconfig.userserverip, Gridconfig.userserverip, Gridconfig.userserverip, Kbase Config.serverip, Kbaseconfig.serverusername, KBASECONFIG.SERVERPSW,"", gridconfig.language}); Restr= Meth. Invoke (obj,New Object[] {US}).                            ToString (); }                        }                    }

In dynamic reference dll-a, when the argument is an entity, and the entity's properties are in another dll-b: We need to get the entity of a and assign it and assign the entity to the Dll-a method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.