在反射读取程序集信息时,在GetTypes时出现ReflectionTypeLoadException异常,如下图所示:

反射ReflectionTypeLoadException异常

这种情况,往往是因为在加载Assembly程序集时,未找到它依赖程序集,最好的解决方法找到它所有依赖程序,保证能读取到目录。

如果实在找不到,只能catch处理:

try
{
   return assembly.GetTypes();
}
catch (ReflectionTypeLoadException e)
{
   return e.Types.Where(t => t != null);
}

相关文章:

  • 2021-07-30
  • 2021-06-16
  • 2021-07-04
  • 2021-08-17
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-31
  • 2021-09-29
  • 2021-12-02
  • 2022-12-23
  • 2021-08-25
相关资源
相似解决方案