Skip to content

Instantly share code, notes, and snippets.

@Layoric
Created July 26, 2013 01:30
Show Gist options
  • Save Layoric/6085319 to your computer and use it in GitHub Desktop.
Save Layoric/6085319 to your computer and use it in GitHub Desktop.
Assembly assembly = Assembly.LoadFile("...Assembly1.dll");
Type type = assembly.GetType("TestAssembly.Main");
if (type != null)
{
MethodInfo methodInfo = type.GetMethod(methodName);
if (methodInfo != null)
{
object result = null;
ParameterInfo[] parameters = methodInfo.GetParameters();
object classInstance = Activator.CreateInstance(type, null);
if (parameters.Length == 0)
{
result = methodInfo.Invoke(classInstance, null);
}
else
{
object[] parametersArray = new object[] { "Hello" };
result = methodInfo.Invoke(classInstance, parametersArray);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment