获取程序集中的类型(错误:System.Reflection.ReflectionTypeLoadException)
我收到类型为“异常详细信息:System.Reflection.ReflectionTypeLoadException:无法加载一种或多种请求的类型。检索 LoaderExceptions 属性以获取更多信息”的异常。使用以下代码:
public IEnumerable<Type> FindClassesOfType(Type assignTypeFrom, IEnumerable<Assembly> assemblies, bool onlyConcreteClasses = true)
{
foreach(var a in assemblies)
{
foreach (var t in a.GetTypes())
我需要获取每个程序集中定义的类型,但似乎无法生成它。
我已经通过删除 dll、清理解决方案、重新加载解决方案等执行了与创建错误程序集相关的所有典型程序,但什么也没发生。
我想请求一些想法,以便通过找到一种方法来检索错误的更多信息,或者找到哪个程序集产生问题或类似的问题来解决这个问题。当前的异常消息非常模糊,无法意识到问题所在。
ps:附加信息,当我运行重建操作时,所有进程都正确生成,没有错误。
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 which assembly is generating problems or something like that. The current exception message is so vague to realize which is the problem.
ps: additional info, when I run the rebuild action all process are correctly generated with no errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
错误消息确实说明了您需要的一切:
The error message says everything you need, really:
如果您使用实体框架,请检查 Web.Config 中的版本是否与您的项目中引用的版本相同。
If you use the Entity Framework, check if version in Web.Config is the same referenced in your project.
DLL是你创建的吗?您的目标是哪个框架?
我刚刚遇到了这个问题。即使使用框架 3.5(使用 CLR2)编译我的外部库,也无法导入 DLL。错误和你的一样。我已经解决了重建针对框架 3.0 的库的问题,并且现在似乎可以工作。我将 dll 留在 Plugins 文件夹中,没有任何问题。
Unity 论坛中有很多类似的问题。
也许您已经有了解决方案,但这可以帮助将来需要它的任何人(就像我需要的那样)。
此致!
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!