Lamp
Lamp

Reputation: 342

Failed to load .NET framework 4.0 dll from .NET 6 project

I have a .NET 6 project and try to load a third-party dll, which build with .NET framework 4.0, dependencies are mscorelib, System.Configuration, System.Data, System.Drawing and System.Core, all are version 4.0.

When I run into the method, the application crashes with exception:

System.IO.FileNotFoundException: Could not load file or assembly '**dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

Seems there are some version conflict between dependent assemblies, but some .NET framework 2.0 dlls works fine. How to resolve this problem if I cannot ask the dll verdor to build a new one?

Upvotes: 0

Views: 793

Answers (1)

SupaMaggie70 b
SupaMaggie70 b

Reputation: 346

If a library uses functions for the .NET Framework, it cannot run on the .NET Core. If it doesn’t, building to the .NET Standard allows it to run on both. Either:

The library is not usable on the .NET Core, in which case your out of luck,

it has separate builds for .NET Framework and .NET Core, in which case you would need to choose the right one,

or the library developer only compiled it for the .NET Framework when it could be compiled otherwise, in which case you could try to compile it yourself.

Upvotes: 1

Related Questions