mercredi 30 mars 2016

Get all class implement specific interface Without loading the assemblies first (dlls)

I would like get a list of all classes implement a specific interface without loading the dll\s first.

Currently I use this code:

Assembly assembly = Assembly.LoadFile(dllPath);
var instances = from t in assembly.GetTypes()
                where t.GetInterfaces().Contains(interfaceType) &&
                t.GetConstructor(Type.EmptyTypes) != null
                select t.Name;
return instances.ToList();

The problem with this code is that it loads all the dependent dlls first, before getting the class names.





Aucun commentaire:

Enregistrer un commentaire