Skip to content

Instantly share code, notes, and snippets.

@restlessmedia
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save restlessmedia/1ac3630dd548f660344f to your computer and use it in GitHub Desktop.
Save restlessmedia/1ac3630dd548f660344f to your computer and use it in GitHub Desktop.
GetLoadedTypes (extension)
/// <summary>
/// Gets the loaded types for this Assembly and skips if any types cannot be loaded when ReflectionTypeLoadException is thrown.
/// </summary>
/// <param name="assembly"></param>
/// <returns></returns>
public static Type[] GetLoadedTypes(this Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
return e.Types.Where(t => t != null).ToArray();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment