Alex Rivera | Logout

Find Types in All Assemblies

Asked 2011-01-14T14:55:47.837
77

I need to look for specific types in all assemblies in a web site or windows app, is there an easy way to do this? Like how the controller factory for ASP.NET MVC looks across all assemblies for controllers.

Thanks.

Edit
Report

1 Answer

34

Easy using Linq:

IEnumerable<Type> types =
            from a in AppDomain.CurrentDomain.GetAssemblies()
            from t in a.GetTypes()
            select t;

foreach(Type t in types)
{
    ...
}
answered 2011-01-15T19:09:29.673

Your Answer