You have to specify which method you want:
class SomeType
{
void Foo(int size, string bar) { }
void Foo() { }
}
SomeType obj = new SomeType();
// call with int and string arguments
obj.GetType()
.GetMethod("Foo", new Type[] { typeof(int), typeof(string) })
.Invoke(obj, new object[] { 42, "Hello" });
// call without arguments
obj.GetType()
.GetMethod("Foo", new Type[0])
.Invoke(obj, new object[0]);
Related Contents:
- Invalid postback or callback argument. Event validation is enabled using ”
- Can you use reflection to find the name of the currently executing method?
- Running .net based application without .NET Framework
- Open Source Alternatives to Reflector? [closed]
- How to loop through all the properties of a class?
- LINQ on the .NET 2.0 Runtime
- Sorting Directory.GetFiles()
- How to prevent ReflectionTypeLoadException when calling Assembly.GetTypes()
- Is it possible to set private property via reflection?
- How to get a Static property with Reflection
- Best way to encode text data for XML
- Call and Callvirt
- Invoking methods with optional parameters through reflection
- Using .Net, how can I determine if a type is a Numeric ValueType?
- How to raise PropertyChanged event without using string name
- .net: System.Web.Mail vs System.Net.Mail
- Redirect Trace output to Console
- How do you get the root namespace of an assembly?
- How to read embedded resource text file
- Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths – why?
- Which method performs better: .Any() vs .Count() > 0?
- Nuget connection attempt failed “Unable to load the service index for source”
- C++/CLI Mixed Mode DLL Creation
- Using Json.NET converters to deserialize properties
- What is the maximum length of an array in .NET on 64-bit Windows
- What’s the difference between KeyDown and KeyPress in .NET?
- Why isn’t there an XML-serializable dictionary in .NET?
- How to apply multiple styles in WPF
- How did Microsoft create assemblies that have circular references?
- How do you parse an HTML in vb.net
- EF LINQ include multiple and nested entities
- Get HTTP requests and responses made using HttpWebRequest/HttpWebResponse to show in Fiddler
- How to use “contains” or “like” in a dynamic linq query?
- NetworkStream.ReadAsync with a cancellation token never cancels
- Resolve Type from Class Name in a Different Assembly
- Check if a property exists in a class
- Enumerating .NET assembly resources at runtime
- WCF: Exposing readonly DataMember properties without set?
- How securely unguessable are GUIDs?
- CLIPBRD_E_CANT_OPEN error when setting the Clipboard from .NET
- Custom app.config Config Section Handler
- Why GetType returns System.Int32 instead of Nullable? [duplicate]
- Using entity framework on multiple databases
- How determine if application is web application
- Data Access Layer design patterns
- How do I install .NET Framework only when it’s not already installed?
- What does “{x:Static}” mean in XAML?
- Getting EOF exception over https call
- How to continue field output on a second page?
- Editable ComboBox with binding to value not in list