Referencing between NetStandard and .Net Framework

Viewed 9408

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

  1. Framework452.Library
  2. NetStandard12.CentralLibrary
  3. NetStandard12.BaseLibrary
  4. Framework452.Tests

The referencing structure is:

  • Framework452.Tests references NetStandard12.CentralLibrary: working by adding the NetStandard.Library nuget package to Framework452.Tests.
  • NetStandard12.CentralLibrary references NetStandard12.BaseLibrary: working without modification.
  • NetStandard12.CentralLibrary references Framework452.Library: Not working, even when Framework452.Library has the NetStandard.Library nuget package installed.

Can NetStandard projects reference Framework projects? If so, what do I need to do to get them to communicate? At the moment I can add the reference, but it is not visible to the code.

Update

I recreated the solution and added the code below, which when I try to compile gives the following error from the Framework452.Tests project:

Error CS0006: Metadata file '~\TryNETStandard\NetStandard12.CentralLibrary\bin\Debug\netstandard1.2\NetStandard12.CentralLibrary.dll' could not be found.

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(); }
    }
}
2 Answers
Related