.NET Core 2.1 无法引用 .NET Framework 4.7.2 类库 [英] .NET Core 2.1 can't reference a .NET Framework 4.7.2 Class library

查看:86
本文介绍了.NET Core 2.1 无法引用 .NET Framework 4.7.2 类库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .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.

这是屏幕截图:

应该有另一个命名空间,一个叫做models

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆