Skip to content

Instantly share code, notes, and snippets.

@haacked
Created January 5, 2013 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save haacked/4463987 to your computer and use it in GitHub Desktop.
Save haacked/4463987 to your computer and use it in GitHub Desktop.
Method to return all loadable types in an assembly. See [this blog post](http://haacked.com/archive/2012/07/23/get-all-types-in-an-assembly.aspx) for details.
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
if (assembly == null) throw new ArgumentNullException("assembly");
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment