Contents

这篇Get All Types in an Assembly文章讲了怎么取到assembly中所有的types。
代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
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);
}
}
Contents