dimanche 21 juin 2015

Finding base type of types loaded from reflection

I have a basic scenario.

Assembly asm = Assembly.LoadFrom(dllPath);
Type[] temp = asm.GetTypes();
bool matchFound = false;
foreach (Type t in temp)
{
    if (t.IsClass && t.IsSubClassOf(typeof(MyBaseClass)))
    {
        Console.WriteLine("Match found");
        matchFound = true;
        break;
    }
}

In this case no match found. But if I add reference of that assembly and call this method again.

bool matchFound = typeof(MyDerivedClass).IsSubClassOf(typeof(MyBaseClass));

matchFound is true in this case.

I want first case to be running. Any suggestion





Aucun commentaire:

Enregistrer un commentaire