System.Reflection.ReflectionTypeloadexception:'无法加载一种或多种请求的类型。无法加载文件或组装

发布于 2025-01-22 05:10:22 字数 2150 浏览 0 评论 0原文

我正在Visual Studio 2019 Net5.0上构建API,当我的程序突然停止工作时,我只是添加了最后的控制器和验证器。

我遇到的错误:

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.'

加载汇编时,我在Statup Configureservices方法上遇到此错误。这是代码:

//use and register all the mappings
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

我尝试遵循这些解决方案,但我无法解决问题: 错误消息'无法加载一种或多种请求类型。检索LoadereXceptions属性以获取更多信息。'

I am building an API on Visual Studio 2019 net5.0 and I was just adding the lasts controllers and validators when my program suddenly stopped working.

The error that I'm getting:

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.
Could not load file or assembly 'Crijoya.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Se ha intentado cargar un programa con un formato incorrecto.'

I get this error on my Statup ConfigureServices method when loading the assemblies. Here's the code:

//use and register all the mappings
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());

I have tried following these solutions but I can't get to the problem:
Error message 'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风疏影 2025-01-29 05:10:22

因此,在我的情况下,dll file crijoya.core的格式不同,如错误所说。在尝试了其他问题之后,这对我有用。

我有一个项目,上面有两个类库,例如so

”在此处输入图像描述

我确保在每个属性中,平台为任何cpu

​Web项目的IIS Express的64位版本

”在此处输入图像描述

So in my case the dll file Crijoya.Core was in a different format as the error says. After trying everything they said on other questions this is what worked for me.

I have a project with two class libraries like so

enter image description here

I made sure that in the properties of each of them the platform was Any CPU

enter image description here

And finally that on Tools I was using the 64 bit version for IIS Express for web projects

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文