c#怎么取到一个dll中所有的类型
这篇Get All Types in an Assembly文章讲了怎么取到assembly中所有的types。
代码如下:
代码如下:
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);
}
}
浙公网安备 33010602011771号