.NET Core 2.1 can't reference a .NET Framework

2020-02-06 06:21发布

I have a .NET Core 2.1 app, a .NET MVC website (4.7.2) and I also have a .NET 4.7.2 class library.

What I'm trying to do is have my core 2.1 project reference the class library.

Now I've added the reference to the core project with no issues (it builds), but when I try to add the namespace to a class It doesn't come up.

I want both the app and the MVC site to share the same class library.

Here's the screen shot:

There should be another namespace, one called models

There should be another namespace, one called models

Any help would be great. Thanks

1条回答
唯我独甜
2楼-- · 2020-02-06 06:55

You can reference .NET Standard library instead. So you need to create .NET Standard library with common shared logic and reference it from both - .NET Core and .NET Framework ("full") projects.

Note that while you may be able to use .NET Standard without PackageReference, it's recommended to do it this way. Find more details in Referencing .NET Standard Assemblies from both .NET Core and .NET Framework.

查看更多
登录 后发表回答