As the documentation for MethodInfo.Invoke states, the first argument is ignored for static methods so you can just pass null.
foreach (var tempClass in macroClasses)
{
// using reflection I will be able to run the method as:
tempClass.GetMethod("Run").Invoke(null, null);
}
As the comment points out, you may want to ensure the method is static when calling GetMethod
:
tempClass.GetMethod("Run", BindingFlags.Public | BindingFlags.Static).Invoke(null, null);
Related Contents:
- How do I reflect over the members of dynamic object?
- Dynamically Add C# Properties at Runtime
- Is the use of dynamic considered a bad practice?
- Dynamic Lang. Runtime vs Reflection
- How do I check if a property exists on a dynamic anonymous type in c#?
- Setting a property by reflection with a string value
- What is the ‘dynamic’ type in C# 4.0 used for?
- How costly is .NET reflection?
- How to Load an Assembly to AppDomain with all references recursively?
- Testing if object is of generic type in C#
- How to get a property value based on the name
- Change Attribute’s parameter at runtime
- Get all derived types of a type
- Get properties in order of declaration using reflection
- Deserializing JSON with dynamic keys
- Is there a way to set properties on struct instances using reflection?
- getting type T from IEnumerable
- Mapping object to dictionary and vice versa
- Creating instance of type without default constructor in C# using reflection
- How To Test if Type is Primitive
- GetMethod for generic method [duplicate]
- Get property name and type using lambda expression
- Fast creation of objects instead of Activator.CreateInstance(type)
- Reflection – Getting the generic arguments from a System.Type instance
- Will the dynamic keyword in C#4 support extension methods?
- Get value of c# dynamic property via string
- Return/consume dynamic anonymous type across assembly boundaries
- Is there a way to get a type’s alias through reflection?
- Resolve Type from Class Name in a Different Assembly
- Check if a property exists in a class
- How to get the value of private field using reflection?
- Create object instance of a class from its name in string variable
- Differences between ExpandoObject, DynamicObject and dynamic
- Get property value from C# dynamic object by string (reflection?)
- Why GetType returns System.Int32 instead of Nullable? [duplicate]
- Finding property differences between two C# objects
- How to pass a parameter as a reference with MethodInfo.Invoke
- How to get MethodInfo of interface method, having implementing MethodInfo of class method?
- How do you get the all properties of a class and its base classes (up the hierarchy) with Reflection? (C#)
- How to find out if a property is an auto-implemented property with reflection?
- How can I get the value of a string property via Reflection?
- Get member to which attribute was applied from inside attribute constructor?
- How to add buttons dynamically to my form?
- Finding all Namespaces in an assembly using Reflection (DotNET)
- Why is the use of reflection in .NET recommended?
- Get class methods using reflection
- How to use local variable as a type? Compiler says “it is a variable but is used like a type”
- Can I get parameter names/values procedurally from the currently executing function?
- C# Reflection: Get *all* active assemblies in a solution?
- Reflection MethodInfo.Invoke() catch exceptions from inside the method