Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add reference to a .NET Core 2.0 DLL on a Full Framework 4.7 project

Tags:

.net

.net-core

I looked for this question in here but I didn't find the answer.

I have a Class Library project targeting .NET Core 2.0 and a WPF project targeting .NET Full Framework 4.7. I can't reference the class library on the WPF project. I get the following error:

Project 'xxxxxxxx' targets '.NETCoreApp,Version=v2.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.7'.

Is there any way to reference a .NET Core project in a Full Framework one?

like image 515
rbasniak Avatar asked Aug 25 '17 00:08

rbasniak


People also ask

How do I reference a DLL in .NET Core?

NET dll directly (and of course still enjoy the benefits of intellisense), basically the same thing as doing Project > Add Reference > Browse in Visual Studio. And that's it! You can still use the GUI in Visual Studio, so this post is targeted more towards devs that either edit the csproj by hand or build for .

Can a .NET Core project reference a .NET framework project?

In Visual Studio 2017.3, you can reference the Full . NET Framework (any version) directly from within a . NetCore2 project.

How do I add a reference to .NET Core library?

Add Class Library Reference To use a class library in your application, you must add a reference to the library to access its functionality. Right click on the project name of your console app in Solution Explorer and select Add ->Reference option.

How do I add an external DLL to .NET Core?

You can do it through Visual Studio UI: right click on Dependencies->Add reference->Browse and select your external . dll . then just remove \bin folder an rebuild the project. It should fix the issue.


1 Answers

You cannot add a reference to a .NET Core project to a .NET Framework project.

To share code between .NET Core and .NET Framework apps / libraries, the shared project must target .NET Standard. If you create a .NET Standard 2.0 project, it can be used in .NET Framework 4.6.1+ projects and .NET Core 2.0+ projects.

like image 115
Martin Ullrich Avatar answered Sep 24 '22 20:09

Martin Ullrich