I want to get the list of classes in an assembly, as an output i want a List[Interface] not a List[string], as "Interface" is the interface from which inherits the classes of my assembly. I don't know if my question makes sense but if any one has the answer i would very much thankful. I already tried this solution: List of classes in an assembly, but it gives a list[string] containing the classes namesso it didn't help because i need the list of the classes that inherits from my interface. Thank you and have a nice day all :)
As an edit for my question, I used activator.createinstance(type t) to create instances of my classes so here is the code :
Assembly assembly = typeof(Interface1<double, double>).Assembly;
List<Interface> Classes = new List<Interface>();
foreach (Type type in assembly.GetExportedTypes())
{
var Attributes = type.GetCustomAttributes<FilterAttribute>();
//select the classes with attribute [Filter]
if (Attributes.Any())
{
TypeOfFilters.Add(type);
}
foreach (var i in TypeOfFilters)
{
var inst = Activator.CreateInstance(i);
Classes.Add((Interface) inst);
}
}
i get the error "System.IO.FileNotFoundException : Could not load file or assembly"
See Question&Answers more detail:os