简体   繁体   中英

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types. Could not load file or assembly

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.'

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

在此处输入图像描述

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

在此处输入图像描述

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM