I created a .Net Standard 2.0 (I tried it as a 2.1 project also, with the same result) to be a bridge between a .Net 4.7.2 project and a .Net Core 6 project. The Standard project references the .Net Core 6 project. The problem is that the Standard project won't build. The following error occurs:
Error CS1705 Assembly 'Core6Proj_XYZ' with identity 'XYZ, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Standard2.0Proj_ABC
Barring implementing a REST API, everything I have found says using .Net Standard as a bridge/wrapper is the only way to consume .Net Core 6 dlls in a .Net 4.x application. Can someone with some experience with this shed some light on what I am missing? Am I confused about how this is supposed to work? Thank you in advance.
CodePudding user response:
That's not how .NET Standard works.
.NET Standard, as the name suggests, provides a set of standard API that are available in all supported runtime/framework versions. You cannot reference a .NET Core/FX assembly in .NET Standard.
If you want to "bridge" two projects with different runtime, you need to put the shared code in another .NET Standard project and reference it from your runtime-specific projects.