获取程序集中的类型(错误:System.Reflection.ReflectionTypeLoadException)
【腾讯云】亏本大甩卖,服务器4核16G 1年370元(带宽12M,系统盘120GB SSD盘,月流量2000GB)!!!!!!
云产品 配置 价格
服务器 1核2G,带宽5M,系统盘50GB SSD盘,月流量500GB 38元/年
MySQL 1核1G 19元/年
服务器 16核32G,带宽18M,系统盘250GB SSD盘,月流量5000GB 1197元/年
点我进入腾讯云,查看更多详情

I´m receiving an Exception of type "Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information." with the following code:

public IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true)
    {
        foreach(var a in assemblies)
        {
            foreach (var t in a.GetTypes())

I need to Get the Types defined in each assembly but it seems that it cannot be generated.

I already performed all typical procedures related to wrong assembly creating by deleting dll´s, clean solution, reload solution, etc but nothing happened.

I would like to request ideas in order to solve this problem by finding a way to retrieve more information of the error, or find wich assembly is generating problems or something like that. The current exception message is so vague to realize which is the problem.

thank you so much. ps: additional info, when I run the rebuild action all process are correctly generated with no errors.

#0

The error message says everything you need, really:

try {
    // your code
} catch (ReflectionTypeLoadException ex) {
    // now look at ex.LoaderExceptions - this is an Exception[], so:
    foreach(Exception inner in ex.LoaderExceptions) {
        // write details of "inner", in particular inner.Message
    }
}

#1

If you use the Entity Framework, check if version in Web.Config is the same referenced in your project.

#2

Was the DLL created by you? Which framework are you targeting?

I've faced this problem just now. Even compiling my external libs with framework 3.5 (that uses CLR2), the DLL coudn't be imported. The error was the same as yours. I've solved my problem rebuilding my libs targeting framework 3.0 and seems to work now. I'm leaving my dlls in Plugins folder with no problems.

There are lots of similar problems in Unity forums.

Maybe you have the solution already, but this can help anyone who needs it in the future (like I needed).

Best Regards!

推荐文章

如何在PDF文件的末尾生成索引?

如何在PDF文件的末尾生成索引?

推荐文章

Localhost on the internet

Localhost on the internet

推荐文章

显示中的块级元素:内联块

显示中的块级元素:内联块

推荐文章

oracle创建索引 查看索引状态

oracle创建索引 查看索引状态

推荐文章

Session.Timeout和Server.ScriptTimeout有什么区别?

Session.Timeout和Server.ScriptTimeout有什么区别?

推荐文章

关于mongodb的安装使用以及java编程

关于mongodb的安装使用以及java编程

推荐文章

这个错误是什么意思:“错误:在'type_name'之前需要说明符限定符列表”?

这个错误是什么意思:“错误:在'type_name'之前需要说明符限定符列表”?

推荐文章

Feature Flags in JavaScript with Vanna

Feature Flags in JavaScript with Vanna

推荐文章

Flash视频-创建虚拟视频剪辑

Flash视频-创建虚拟视频剪辑

推荐文章

tablespace概念与创建

tablespace概念与创建

推荐文章

foreach循环中的动态行和列

foreach循环中的动态行和列

推荐文章

为什么要将SQL关键字大写?

为什么要将SQL关键字大写?

推荐文章

Software Architecture Demystified

Software Architecture Demystified

推荐文章

Creating a text editor in Electron: part 1 - Reading files

Creating a text editor in Electron: part 1 - Reading files

推荐文章

如何完全删除标识

如何完全删除标识

推荐文章

那些年,我使用过的轮子

那些年,我使用过的轮子