Microsoft.CSharp.RuntimeBinder.RuntimeBinderException when using a dynamic parameter

0

In order to use any version of an API, I am choosing the DLL at runtime. In this DLL (ExternalDLL), there is a class like this one:

public class NameClass
{
    private string firstN;
    private string lastN;

    public NameClass(string firstN, string lastN)
    {
        this.firstN = firstN;
        this.lastN = lastN;
    }
}

public class MyClass
{
    private List<NameClass> listN = new List<NameClass>();
    public int CurrentIndex;

    public void GetName(out NameClass nclass)
    {
        if (CurrentIndex > -1 && CurrentIndex < listN.Count) nclass = listN[CurrentIndex];
        else nclass = null;
    }

}

So, the exception is raised when I try to use the method GetName()

dynamic myClass = Activator.CreateInstance("ExternalDLL.MyClass");
dynamic nameClass = Activator.CreateInstance("ExternalDLL.NameClass");
myClass.GetName(out nameClass);

When the method is called I get the RuntimeBinderException with this information:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException occurred HResult=0x80131500 Message=A melhor correspondência de método sobrecarregado 'Tekla.Structures.Model.ModelObject.GetPhase(out Tekla.Structures.Model.Phase)' tem alguns argumentos inválidos

c#
dynamic
asked on Stack Overflow Oct 8, 2018 by Bernardo Garcia • edited Oct 9, 2018 by Bernardo Garcia

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0