.NET Framework 4.6、.Net Native 和 .Net Core 之间的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29609993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 09:38:52  来源:igfitidea点击:

Difference between .NET Framework 4.6, .Net Native and .Net Core

.net.net-core

提问by user203687

I see the following in almost every future .NET framework discussion:

我在几乎所有未来的 .NET 框架讨论中都会看到以下内容:

  • .NET Framework 4.6 (Full .Net framework)
  • .NET Native
  • .NET Core
  • .NET Framework 4.6(完整的 .Net 框架)
  • .NET 原生
  • .NET 核心

What is the difference between all of these?

所有这些之间有什么区别?

How do I know when to use the appropriate one?

我怎么知道什么时候使用合适的?

回答by user203687

After going through various links and videos, I found an interesting picture as a whole:

翻遍了各种链接和视频,整体上发现了一张有趣的图:

.NET Framework 4.6, .Net Native and .NET Core

.NET Framework 4.6、.Net Native 和 .NET Core

From the above, we could easily deduce the following:

综上所述,我们可以很容易地推断出以下几点:

  • .NET Framework 4.6is a full framework for everything related to .NET, but lacks libraries & runtime optimized for multi-platform (Windows, Linux and Mac) and cloud deployments
  • .NET Coreon the other hand is a subset of .NET Framework 4.6 which is mainly optimized for multi-platform and cloud deployments
  • .NET Nativeis mainly used to develop Universal Apps which will be quite optimized to run on any device and platform, natively (not for the web apps though)
  • .NET Framework 4.6是与 .NET 相关的所有内容的完整框架,但缺少针对多平台(Windows、Linux 和 Mac)和云部署优化的库和运行时
  • 另一方面,.NET Core是 .NET Framework 4.6 的一个子集,主要针对多平台和云部署进行了优化
  • .NET Native主要用于开发通用应用程序,这些应用程序将非常优化以在任何设备和平台上运行,本机(但不适用于 Web 应用程序)

An interesting point is ASP.NET:

一个有趣的点是 ASP.NET:

  • If we need backward compatibility to the fullest extent (say web forms or aspx support), we need to go with .NET Framework 4.6
  • If we develop MVC, Web API or Razor web pages, then we can deploy those web apps either in .NET Framework 4.6 or .NET Core environment
  • 如果我们需要最大程度的向后兼容性(比如 Web 表单或 aspx 支持),我们需要使用 .NET Framework 4.6
  • 如果我们开发 MVC、Web API 或 Razor 网页,那么我们可以在 .NET Framework 4.6 或 .NET Core 环境中部署这些 Web 应用程序

回答by Tim P.

TLDR: If it's Core, it's a subset of functionality so it can be ran cross-plat. Anything you can run on Core can be ran on the full 4.6 framework for Windows.

TLDR:如果它是 Core,则它是功能的子集,因此可以跨平台运行。您可以在 Core 上运行的任何内容都可以在适用于 Windows 的完整 4.6 框架上运行。

.NET Framework v4.6-- The full framework that can only run on Windows. However, because this is the fullframework, that means you get WCF, WPF, and all functionality. You can think of this as your normal .NET Windows development that you're probably doing today. It does include ASP.NET WebForms, MVC, Core, and SignalR. If you're using .NET 4.5 today, this is your next natural upgrade path.

.NET Framework v4.6-- 只能在 Windows 上运行的完整框架。但是,因为这是完整的框架,这意味着您可以获得 WCF、WPF 和所有功能。您可以将其视为您今天可能正在执行的常规 .NET Windows 开发。它确实包括 ASP.NET WebForms、MVC、Core 和 SignalR。如果您现在使用 .NET 4.5,这是您的下一个自然升级路径。

.NET Core-- A subset framework that doesn't include everything in the full 4.6 Framework. However it is intended to run cross-platform on Windows, Mac, or Linux. You do lose some functionality however, such as WCF, WPF. But you'll still have ASP.NET Core (no WebForms), but not SignalR yet. SignalR support is intended to come in a later version. This uses the dotnet CLI (command-line interface) for compiling applications, or if you're on Windows then you can use Visual Studio.

.NET Core——一个子集框架,不包括完整 4.6 框架中的所有内容。但是,它旨在在 Windows、Mac 或 Linux 上跨平台运行。但是,您确实会丢失一些功能,例如 WCF、WPF。但您仍将拥有 ASP.NET Core(没有 WebForms),但还没有 SignalR。SignalR 支持旨在提供更高版本。这使用 dotnet CLI(命令行界面)来编译应用程序,或者如果您使用的是 Windows,那么您可以使用 Visual Studio。

.NET Native-- Native compilation of the .NET Core framework. Instead of doing normal JIT compiling at runtime of your .exe, this will do an AOT compilationthat can potentially do some better optimizations of your code using the C++ backend compiler(or LLVM using LLILC). When you do this, you are targeting a specific platform, such as "Linux 64-bit". The benefits are quicker start-up times, potentially smaller memory requirements, hopefully better runtime performance, and emits only one single binary file (you won't need to install the .NET Framework on the target machine). The tradeoff however is portability to other platforms--you'll have separate binaries for Linux, MacOS, Windows, 32-bit, 64-bit, etc. This currently only works for Windows Store apps but more work is being done so it'll work on normal .NET apps, including ASP.NET apps. Currently not slated to be part of the .NET Core 1.0 release.

.NET Native- .NET Core 框架的本机编译。这将执行AOT 编译,而不是在您的 .exe 运行时进行正常的 JIT 编译,它可能会使用 C++ 后端编译器(或使用LLILC 的LLVM)对您的代码进行一些更好的优化)。执行此操作时,您的目标是特定平台,例如“Linux 64 位”。好处是启动时间更快,内存需求可能更小,运行时性能有望更好,并且只发出一个二进制文件(您不需要在目标机器上安装 .NET Framework)。然而,权衡是对其他平台的可移植性——您将拥有适用于 Linux、MacOS、Windows、32 位、64 位等的单独二进制文件。这目前仅适用于 Windows Store 应用程序,但正在做更多的工作,所以它将适用于普通的 .NET 应用程序,包括 ASP.NET 应用程序。目前不打算成为 .NET Core 1.0 版本的一部分。

ASP.NET Core-- The new way of doing web development on .NET Core or Full Framework. It includes a customizable HTTP pipeline, Kestrel web server, and better performanceprofiles than the previous ASP.NET 4.x version. This is cross-platform compatible across both the full framework and the Core framework. It does not include WebForms, or SignalR support (yet). It is not backwards compatible with ASP.NET 4, although if you're using MVC/WebAPI now, then MVC/WebAPI going forward should be fairly close since there will only be one Controllerclass. If you're wanting to use WebForms, then you have no choice but to stick with the full 4.6 Framework.

ASP.NET Core-- 在 .NET Core 或完整框架上进行 Web 开发的新方法。它包括一个可定制的 HTTP 管道、Kestrel Web 服务器以及比以前的 ASP.NET 4.x 版本更好的性能配置文件。这是跨完整框架和核心框架的跨平台兼容。它不包括 WebForms 或 SignalR 支持(尚未)。它不与 ASP.NET 4 向后兼容,尽管如果您现在使用 MVC/WebAPI,那么 MVC/WebAPI 应该非常接近,因为只有一个Controller类。如果您想使用 WebForms,那么您别无选择,只能坚持使用完整的 4.6 框架。

Entity Framework Core-- The new framework for ORM development. Once called EF7, it is the cross-platform ORM framework that works for both the full 4.6 stack and also the new Core stack. It is not backwards compatible with EF6. It only supports a code-first model. There may be tooling in the future to help upgrade existing EF6 .edmx files to generate the classes for code-first EFCore implementation.

Entity Framework Core——ORM 开发的新框架。曾经被称为 EF7,它是跨平台 ORM 框架,适用于完整的 4.6 堆栈和新的 Core 堆栈。它不向后兼容 EF6。它仅支持代码优先模型。未来可能会有工具帮助升级现有的 EF6 .edmx 文件,以生成代码优先 EFCore 实现的类。