How to reference a dotNet Core project?

2019-07-10 15:20发布

问题:

I want to reference a dotNet Core project to a WPF project.

My WPF project is using the v4.6.2 dotNet Framework and my dotNet Core project is using the v1.6 dotNet Standard.

When I try to reference it, I get this error:

回答1:

v1.6 .Net Core isn't compatible with v4.6.2 .Net according to the docs.

So I changed it to v1.5 .Net Core.



回答2:

I found this YouTube video. The easiest way is to write this in the *.csproj

<TargetFrameworks>netcoreapp2.0;net462</TargetFrameworks>

instead of this

<TargetFramework>netcoreapp2.0</TargetFramework>

Important notes: don't forget the extra s in targetframeworkS. You should at least have Runtime and DevPack of .NET Core 4.6.2.(get it here). After the change you often have to right click unload and then right click reload the project.