Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

error loading assembly from .net framework to .net standard to .net core

I'm currently working on a .NET core application. I need to use an assembly which was originally written in C++ using some .NET Framework libraries. In any case, I can only use the final DLL in my .NET Core project.

I made a workaround and put my business logic into a .NET Standard project, to be able to use the .NET Framework in my .net Core project.

Unfortunately I'm getting the following error, when I try to load the .net standard service (which loads the .net framework part) in my .net core project:

System.BadImageFormatException: Could not load file or assembly XXX. An attempt was made to load a program with an incorrect format.

In my .net Core project, I register the .net Standard service like this:

services.AddSingleton<IFruitsManager, FruitsManager>();

In my .net core controller class, I can inject the IFruitsManager and get an instance:

private readonly IFruitsManager manager;

public FruitsController(IFruitsManager manager)
{
   this.manager = manager;
}

As soon as I try to call a method from the manager, I get the error.

var result = manager.CreateFruits(); // BadImageFormatException is thrown at this point

Do you have any idea on how to solve this problem?

Comments