Currently, there are not only APIs in .NET Framework that is not available in .NET Core (e.g. Remoting, WCF hosting, additional App Domains), but there are now also APIs in .NET Core that aren't available on .NET Framework - this includes useful additions to the base class library and a lot of Span<T>
based APIs that have been added to base .NET types in .NET Core 2.1.
In order to create libraries that can be used on both frameworks, use .NET Standard.
Technically, the biggest difference between .NET Framework and .NET Core is where (.dll files) the frameworks actually carry their implementations and type definitions.
While .NET Framework has a lot of base types in mscorlib.dll
, .NET Core may carry them inside System.Runtime.dll
or System.Private.CoreLib.dll
.
A type reference always includes the name of the assembly and the namespace+type name. If the framework you run on has System.Object
defined in mscorlib
but an application references [System.Runtime]System.Object
, it may fail to load.
.NET Core 2.0 has invested effort to at least provide type forwarders so that references are redirected to the correct assemblies. So the .NET Framework compatibility may redirect [mscorlib]System.Object
to [System.Runtime]System.Object
when loading .NET Framework assemblies. (see Compatibility shim used by .NET Standard 2.0)
The same may not work the other way around. While newer versions of .NET Framework provide a lot of the same assemblies (implemented via type forwarding) that .NET Core uses, it only guarantees .NET Standard compatibility. If you target older versions of .NET Framework, additional type forwarding DLLs will be added to the build output to provide this compatilbity (see Why does my .NET Standard NuGet package trigger so many dependencies?).
This may enable loading some .NET Core dll files on .NET Framework to some degree, but there is no guarantee that it may work. It will fail if the dll uses APIs unavailable on .NET Framework but may also fail when it references a type with an assembly name that is not available.
Note that this only applies to loading dll files. Project-to-Project references will fail since the tooling should forbid referencing .NET Core projects from .NET Framework projects.