Link between NetStandard and .Net Framework

I am trying to get .Net Framework and NetStandard assemblies to communicate with each other (to find out what is possible). I currently have four projects, two Framework 4.5.2 projects and two NetStandard1.2 projects:

  • Framework452.Library
  • NetStandard12.CentralLibrary
  • NetStandard12.BaseLibrary
  • Framework452.Tests

Link Structure:

  • Framework452.Testslinks NetStandard12.CentralLibrary: we work by adding the NetStandard.Library nuget package to Framework452.Tests.
  • NetStandard12.CentralLibrarylinks NetStandard12.BaseLibrary: work without changes.
  • NetStandard12.CentralLibrarylinks Framework452.Library: does not work even if Framework452.LibraryNetStandard.Library nuget is installed.

Can NetStandard projects refer to Framework projects? If so, what do I need to do to make them communicate? At the moment I can add a link, but the code is not displayed.

Update

, , , Framework452.Tests:

CS0006: '~\TryNETStandard\NetStandard12.CentralLibrary\Bin\Debug\netstandard1.2\NetStandard12.CentralLibrary.dll' .

namespace Framework452.Library
{
    public class Returner452 {
        public static bool ReturnTrue() { return true; }
    }
}


using Xunit;
namespace Framework452.Tests
{
    public class Class1 {
        [Fact]
        public void FrameworkTest() {
            Assert.True(NetStandard12.CentralLibrary.Class1.Return452());
        }

        [Fact]
        public void NetStandardTest() {
            Assert.True(NetStandard12.CentralLibrary.Class1.Return12());
        }
    }
}


namespace NetStandard12.BaseLibrary
{
    public class Returner12 {
        public static bool ReturnTrue() { return true; }
    }
}


using Framework452.Library;
using NetStandard12.BaseLibrary;
namespace NetStandard12.CentralLibrary
{
    public class Class1
    {
        public static bool Return452() { return Returner452.ReturnTrue(); }
        public static bool Return12() { return Returner12.ReturnTrue(); }
    }
}
+4
2

https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-platforms-support , .NET Standard 1.2 .NET Framework 4.5.1 ( UPDATE: 100%. . "" .)

VS 2017 , . .

Solution Browser

Class1.cs NetStandard12.CentralLibrary

Class1.cs

.

: , Framework452.Library API, .NET Standard 1.2 (, Winforms, Win32 API Microsoft, -).

youtube .NET MSFT https://www.youtube.com/watch?v=YI4MurjfMn8&list=PLRAdsfhKI4OWx321A_pr-7HhRNk7wOLLY

.NET Standard - , , , API .NET.

.NET Standard 2.0 "compat shim"

UPDATE

, , , ().NET Standard , .NET Framework. - , . ​​.

, NetStandard NetFramework: .NET Standard .NET Platform. Interface hierarchy , , , .NET Standard, / .NET.

.NET Standard 2, , .NET Framework Compatibility Shim. https://youtu.be/vg6nR7hS2lI?list=PLRAdsfhKI4OWx321A_pr-7HhRNk7wOLLY&t=169

+3

, .NET Standard .

.NET , .NET, , .

, , Microsoft .NET Standard 2.0, , .

+4

Source: https://habr.com/ru/post/1682172/


All Articles