assembly fill complex type by reflection December 15, 2014
Posted by juanpablo1manrique in SharePoint.trackback
The code say everything
string dllName = “Mycomponent.dll”;
string typeEntityName = “Mycomponent.DBEntity”;
Assembly assembly = Assembly.LoadFrom(“C:\\” + dllName);
Type typeEntity = assembly.GetType(typeEntity);
object objByreflection = Activator.CreateInstance(typeEntityName);
//ahora la magia
PropertyInfo pinfoprop1 = typeEntity.GetProperty(“prop1”);
pinfoprop1.SetValue(objByreflection, value1, null);
PropertyInfo pinfoprop2 = typeEntity.GetProperty(“prop2”);
pinfoprop2.SetValue(objByreflection, value2, null);
return objByreflection;
Comments»
No comments yet — be the first.