.NET Core 2.1无法引用.NET Framework 4.7.2类库 [英] .NET Core 2.1 can't reference a .NET Framework 4.7.2 Class library
问题描述
我有一个.NET Core 2.1应用程序,一个.NET MVC网站(4.7.2),也有一个.NET 4.7.2类库。
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.
我要做的是让我的核心2.1项目引用类库。
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.
我希望应用程序和MVC网站都共享同一个类库。
I want both the app and the MVC site to share the same class library.
以下是屏幕截图:
应该有另一个名称空间,称为模型
There should be another namespace, one called models
任何帮助都将非常有用。
谢谢
Any help would be great. Thanks
推荐答案
您可以引用 .NET Standard
库。因此,您需要使用通用的共享逻辑创建 .NET Standard
库,并从两者中引用- .NET Core
和 .NET Framework(完整)
项目。
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.
请注意,尽管您可能会能够在不使用 PackageReference
的情况下使用 .NET Standard
的方法,建议这样做。在从.NET Core和.NET Framework引用.NET标准程序集中查找更多详细信息。
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.
这篇关于.NET Core 2.1无法引用.NET Framework 4.7.2类库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!