.net.net-core

How do I reference a .NET Core library in a .NET Framework 4.5.1 project?


When I try to add a reference to a .NET Core library in a class library project for .NET Framework 4.5.1, the following error showed up:

A reference to 'Idea7.Entity' could not be added. An assembly must have a 'dll' or 'exe' extension in order to be referenced.

enter image description here

Here is the config.json from the .NET Core project's Idea7.Entity:

{
  "version": "1.0.0-*",
  "description": "Idea7.Entity Class Library",
  "authors": [ "Sebastian Bušek" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "frameworks": {
    "net451": { },
    "dotnet5.4": { }
  },
  "dependencies": {
    "Microsoft.CSharp": "4.0.1-beta-23516"
  }
}

Why am I not able to use class library targeting .NET Core in a .NET Framework 4.5.1 class library?


Solution

  • It's not possible to reference a .NET Core class library in a .NET Framework 4.5.1 class library project in Visual Studio by click "Add reference"; but you can add a reference to a built *.dll.

    To do that, you need to do the following steps: