Aufrufen einer Methode einer generischen Klasse

Hier ist der Kontext:

Ich versuche, einen Mapper zum dynamischen Konvertieren meiner DomainModel-Objekte in ViewModel-Objekte zu codieren. Das Problem, das ich bekomme, ist, wenn ich versuche, eine Methode der generischen Klasse durch Reflektion aufzurufen, erhalte ich diesen Fehler:

System.InvalidOperationException: Spät gebundene Operationen können nicht für Typen oder Methoden ausgeführt werden, für die ContainsGenericParameters true ist.

Kann mir jemand helfen, herauszufinden, wo der Fehler liegt? Es wäre sehr dankbar

Hier ist der Code (ich habe versucht ihn zu vereinfachen):

public class MapClass<SourceType, DestinationType>
{

    public string Test()
    {
        return test
    }

    public void MapClassReflection(SourceType source, ref DestinationType destination)
    {
        Type sourceType = source.GetType();
        Type destinationType = destination.GetType();

        foreach (PropertyInfo sourceProperty in sourceType.GetProperties())
        {
            string destinationPropertyName = LookupForPropertyInDestinationType(sourceProperty.Name, destinationType);

            if (destinationPropertyName != null)
            {
                PropertyInfo destinationProperty = destinationType.GetProperty(destinationPropertyName);
                if (destinationProperty.PropertyType == sourceProperty.PropertyType)
                {
                    destinationProperty.SetValue(destination, sourceProperty.GetValue(source, null), null);
                }
                else
                {

                       Type d1 = typeof(MapClass<,>);
                        Type[] typeArgs = { destinationProperty.GetType(), sourceType.GetType() };
                        Type constructed = d1.MakeGenericType(typeArgs);

                        object o = Activator.CreateInstance(constructed, null);

                        MethodInfo theMethod = d1.GetMethod("Test");

                        string toto = (string)theMethod.Invoke(o,null);

                }
                }
            }
        }


    private string LookupForPropertyInDestinationType(string sourcePropertyName, Type destinationType)
    {
        foreach (PropertyInfo property in destinationType.GetProperties())
        {
            if (property.Name == sourcePropertyName)
            {
                return sourcePropertyName;
            }
        }
        return null;
    }
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage