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.