.NET Core项目添加了对.NET Framework项目的引用.为什么有可能呢? [英] .NET Core project add reference to .NET Framework project. Why it's possible?

查看:339
本文介绍了.NET Core项目添加了对.NET Framework项目的引用.为什么有可能呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下项目:

.NET Core 2.0 Web应用程序

.NET Core 2.0 Web Application

.NET Standard 2.0类库&

.NET Standard 2.0 Class library &

.NET Framework 4.5类库.

.NET Framework 4.5 Class Library.

我将.net框架类库的引用添加到asp.net核心Web api项目中.看来效果很好.

I add reference of .net framework class library to asp.net core web api project. and it seems it works very well.

我想知道为什么可以在ASP.NET Core Web API或MVC中添加.NET Framework类库项目的引用?

I am wondering why it's possible to add reference of .NET Framework class library project to ASP.NET Core Web API or MVC?

不应该只允许将Standard或Core库引用添加到Core项目吗? 带有.NET Framework类库引用的核心Web项目是否仍跨平台?

It's not supposed to allow adding only Standard or Core libraries references to Core projects? Is this core Web project with .NET Framework class libraries references still cross platform?

更新

根据 Phiter 评论:

如果将.net框架库导入到项目中,它将不再是跨平台的,但是如果愿意,您可以自由地进行操作.他们允许这样做,因为您可能想使用.net核心并且仍然可以在Windows上."

"If you import a .net framework library to your project it'll no longer be cross platform, but you can do it freely if you want to. They allow it because you might want to use .net core and still be on windows."

因此,如果这是一个原因,如果我想将我的项目绑定到.NET Framework并保留在Windows上,为什么要从一开始就使用Core Web Project?

So if this is a reason, if I want to bind my project to .NET Framework and remain on windows why I use Core Web Project from the first place?

我认为我们将核心项目用于跨平台功能,如果没有,.Net框架不是更好的选择吗?

I thought we use core projects for cross platform ability and if not, the .Net framework is not a better option?

更新

梅森评论:

没什么好笑的:ASP.NET Core项目不必在.NET Core上运行.它也可以在.NET Framework上运行.

"Nothing funny: ASP.NET Core project doesn't have to run on .NET Core. It can also be run on .NET Framework.

仅仅因为它被称为核心",并不意味着它们之间是有联系的.他们可以将其称为ASP.NET FancyPants,并使其在.NET Core和.NET Framework上运行,您不会感到困惑.微软只是在为事物命名."

Just because it's called 'Core' doesn't mean they're related. They could have called it ASP.NET FancyPants and had it run on .NET Core and .NET Framework and you wouldn't be as confused. Microsoft just sucks at naming things."

更新(2018年11月12日)

A first look at changes coming in ASP.NET Core 3.0 - Fully leveraging .NET Core

ASP.NET Core只能在从3.0开始的.NET Core上运行..展望未来,您可以简单地将ASP.NET Core视为.NET Core的一部分.

As announced on the .NET Blog earlier this month, .NET Framework will get fewer of the newer platform and language features that come to .NET Core moving forward, due to the in-place update nature of .NET Framework and the desire to limit changes there that might break existing applications. To ensure ASP.NET Core can fully leverage the improvements coming to .NET Core moving forward, ASP.NET Core will only run on .NET Core starting from 3.0. Moving forward, you can simply think of ASP.NET Core as being part of .NET Core.

当今在.NET Framework上使用ASP.NET Core的客户可以继续使用.NET Core支持策略.

Customers utilizing ASP.NET Core on .NET Framework today can continue to do so in a fully supported fashion using the 2.1 LTS release. Support and servicing for 2.1 will continue until at least August 21, 2021 (3 years after its declaration as an LTS release) in accordance with the .NET Core support policy.

推荐答案

这是作为

This was just added as part of .NET Standard/Core 2.0. As long as the .NET Framework dll only references things in the .NET Standard, it will use type forwarding to the .NET Core implementations.

这篇关于.NET Core项目添加了对.NET Framework项目的引用.为什么有可能呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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