jump to navigation

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: