I have some dll that is written in .Net
framework 4.0
and I can't run my program when I'm referencing it to my project which is written in .NET core 2.0
.
Although my IDE (vs 2017) can recognize the objects imported from that dll correctly in run time Im having the following exception:
System.BadImageFormatException: 'Could not load file or assembly 'A_dotnet_4.0_A, Version=10.0.0.0, Culture=neutral, PublicKeyToken=0ad20d08c672086a'. An attempt was made to load a program with an incorrect format.'
I tried to:
Is it even possible? and if it does, how should I do so. In the following link is seem like it is possible - I just can't understand how.
NET Core, you need to use the . NET Framework. You can now reference . NET Framework libraries from .
Yes, you can load . NET Framework assemblies into . NET Core 5 and 6.
To do that, complete the following steps: In Visual Studio select Analyze and then Portability Analyzer Settings. In the General Settings window, select . NET Standard 2.0 under Target Platforms, and then choose OK.
You cannot do this.
.NET Core can reference a .NET Standard DLL
.NET Framework can reference a .NET Standard DLL
.NET Core cannot reference a .NET Framework DLL (or visa versa).
If you have for example a .NET Standard Project, you cannot reference .NET Framework and the .NET Core framework.
It's one or the other.
To further elaborate on this, we have a project that has shared BusinessLogic, that project is a .NET Standard 2.0 Library.
We reference that project in 2 other projects a.NET Core 2.1 and a .NET Framework 4.7.
Things go wrong when you reference .NET Core or .NET Framework items directly to that shared .NET Standard library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With