Question: I am trying load a function in a dll. The dll is loaded but just at the place of invoking the function, I am getting an exception

> 
> Ambiguous match found
> 
> 
> 

Here is the code snippet.

```
Assembly dll = Assembly.LoadFrom(DLLPATH);
if (dll != null)
{
    Type Tp = dll.GetType("ABCD.FooClass");
    if (Tp != null)
    {
        Object obj = Activator.CreateInstance(Tp);

        if (obj != null)
        {                            
            List = (List<String>)obj.GetType().GetMethod("Foo").Invoke(obj, null);
        }
        else
        {
            Console.WriteLine("obj is null");
        }
    }
    Console.WriteLine("Type is null");
}
else
    Console.WriteLine("Dll is not loaded");

Console.ReadKey();

```

The method which I am calling (i.e `Foo`), **does not accept any parameters** and it is an overloaded method. Is that the place where I am going wrong or is it some other place?

Is there another way to invoke such methods which does not accept any parameters? I tried the solution posted [here](https://stackoverflow.com/questions/223495/how-to-use-reflection-to-invoke-an-overloaded-method-in-net) but it is not working.

Answer: 
If there is an overload and you want to invoke the method with no parameters this is the correct solution:

```
MethodInfo mi = obj.GetType().GetMethod("Foo", new Type[] { });

```
Thanks guys for your help.!! 

As I told you, the method (i.e FOO) which I was calling, is overloaded. I did not used GetMethod() properly I suppose. Now, I found a solution using GetMethods() function.

I changed my code in following way and it worked.!!

```
Assembly dll = Assembly.LoadFrom(DLLPATH);
if (dll != null)
{
   Type Tp = dll.GetType("ABCD.FooClass");
   if (Tp != null)
   {
      Object obj = Activator.CreateInstance(Tp);
      if (obj != null)
      {                            
         MethodInfo[] AllMethods = obj.GetType().GetMethods();
         MethodInfo Found = AllMethods.FirstOrDefault(mi => mi.Name == "Foo" && mi.GetParameters().Count() == 0);
         if (Found != null)
             List = (List<String>)Found.Invoke(obj, null);           
      }
      else
        Console.WriteLine("obj is null");       
   }
    else
     Console.WriteLine("Type is null");
 }
  else
     Console.WriteLine("Dll is not loaded");

```