vendredi 18 septembre 2020

C# reflection get types from referenced project

I'm trying to get types declared in another my project referenced by my project with Unit Tests:

var allTypes = AppDomain.CurrentDomain.GetAssemblies().SelectMany(t => t.GetTypes())
                .Where(t => t.IsClass && t.Namespace != null && t.Namespace.StartsWith("MyProject"))
                .ToList();

It returns only types from the Unit Test project (the namespace is also starting with "MyProject"). What I'm doing wrong?





Aucun commentaire:

Enregistrer un commentaire