Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Framework dll not working on .Net Standard project

I have referenced the .Net framework ddl to .Net standard 2.0. It will show me below errors.

System.Reflection.ReflectionTypeLoadException: 'Unable to load one or more of the requested types.
The given assembly name or codebase, '\bin\Debug\netcoreapp2.1\FirstDataBank.DrugServer.API.dll', was invalid.
The given assembly name or codebase, '\bin\Debug\netcoreapp2.1\FirstDataBank.DrugServer.API.dll', was invalid.
The given assembly name or codebase, '\bin\Debug\netcoreapp2.1\FirstDataBank.DrugServer.API.dll', was invalid.
The given assembly name or codebase, '\bin\Debug\netcoreapp2.1\FirstDataBank.DrugServer.API.dll', was invalid.'

Same ddl working fine on .Net framework project but for .Net standard it will show an error.

like image 656
Hiteshkumar Vaghasiya Avatar asked Dec 10 '22 02:12

Hiteshkumar Vaghasiya


2 Answers

This simply isn't supported.

You may reference some (but not all) .NET Standard Libraries from a .NET Framework project, but the other way is not supported.

.NET Standard is designed to support code sharing among different platforms, but .NET Framework only supports Windows.

To get you started on the topic, here is a nice post that explains it pretty short: Difference between Standard, Framework and Core

like image 156
Michael Sander Avatar answered Dec 12 '22 23:12

Michael Sander


".Net Framework dll not working on .Net Standard project" - well, yes; that's normal and expected; if you need to consume something that is only available for .NET Framework (not .NET Standard), then: you should only be consuming it from a project that itself targets .NET Framework; alternatively: consider re-targeting or multi-targeting the library that you're consuming (if you control it; otherwise: ask the supplier), ideally so that it is available as a nupkg that targets .NET Standard, or that multi-targets .NET Framework and .NET Standard.

like image 45
Marc Gravell Avatar answered Dec 12 '22 22:12

Marc Gravell