Skip to content

Instantly share code, notes, and snippets.

@burkeholland
Created April 14, 2011 21:43
Show Gist options
  • Save burkeholland/920628 to your computer and use it in GitHub Desktop.
Save burkeholland/920628 to your computer and use it in GitHub Desktop.
var assembly = Assembly.GetCallingAssembly();
var instance = assembly.CreateInstance("MyProject.MyClass", true,
BindingFlags.CreateInstance, null, new object[]
{ monitor, action }, null, null);
var t = instance.GetType();
// if you have a property you want to pass
// a value to, this is how you do it.
var p = t.GetProperty("MyProperty");
p.SetValue(instance, propertyValue, null);
MethodInfo info = t.GetMethod("Run");
var result = info.Invoke(instance, args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment