Created
December 27, 2011 02:56
-
-
Save posaunehm/1522588 to your computer and use it in GitHub Desktop.
AssemblyExtension: A GetTypes method which have exception-ignoring option.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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