I have an ASP.NET Core 2.1 application referencing in a solution couple of .NET Standard 2.0 projects. I want to use reflection and get all types from the referenced assemblies, trying the below code gives me pretty much all Microsoft assemblies but the referenced types are not there.
var allAssembliesTypes = Assembly.GetExecutingAssembly().GetReferencedAssemblies()
.Select(a => a.GetType()).ToList();
List<Type> handlerTypes = allAssembliesTypes
// typeof(ICommand).Assembly.GetTypes()
.Where(x => x.GetInterfaces().Any(y => IsHandlerInterface(y)))
.Where(x => x.Name.EndsWith("Handler"))
.ToList();
handlerTypes
is always empty and I do have types ending with *Handler name.
Aucun commentaire:
Enregistrer un commentaire