Skip to content

Instantly share code, notes, and snippets.

@posaunehm
Created December 27, 2011 02:56
Show Gist options
  • Save posaunehm/1522588 to your computer and use it in GitHub Desktop.
Save posaunehm/1522588 to your computer and use it in GitHub Desktop.
AssemblyExtension: A GetTypes method which have exception-ignoring option.
public static Type[] GetTypes(this Assembly assembly, bool ignoreReflectionTypeloadException)
{
if(ignoreReflectionTypeloadException)
{
Type[] types;
try
{
types = assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
types = ex.Types;
}
return types;
}
else
{
return assembly.GetTypes();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment