I want to loop over all classes which I have added in my project
Assembly[] foo = AppDomain.CurrentDomain.GetAssemblies();
foreach(Assembly a in foo)
{
foreach(Type t in a.GetTypes())
{
}
}
this is what I tried but I want to exclude the assemblies which are provided by .net, for example “mscorlib”
One common solution would be to filter the assemblies by name, if all of your assemblies have a common prefix (if you have a more or less unique prefix).
If you are only interested in some specific types, consider using attributes for your classes, or even add one at assembly level.
Example:
Create an attribute:
add the following to your AssemblyInfo.cs:
and filter the assemblies you are looking at:
Also you will find at this question interesting. In one answer it is suggested to check the fully qualified name of each assembly, but this is quite tedious, e.g.:
It’s always easier to mark your assemblies (by name or attribute) than trying to identify which ones are part of the .Net framework.