.NET Core、.NET Framework 和 Xamarin 之间有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38063837/
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:48:52  来源:igfitidea点击:

What's the difference between .NET Core, .NET Framework, and Xamarin?

.netxamarin.net-core

提问by MeeChao

Microsoft now has .NET Core, .NET Framework and Xamarin (Mono) in its .NET family.

微软现在在其 .NET 系列中拥有 .NET Core、.NET Framework 和 Xamarin (Mono)。

There seems to be a lot of overlap here. What's the difference between these types of .NET? When should I choose to use .NET Core in my project, instead of .NET Framework or Xamarin?

这里似乎有很多重叠。这些类型的 .NET 之间有什么区别?我什么时候应该选择在我的项目中使用 .NET Core,而不是 .NET Framework 或 Xamarin?

采纳答案by Fiona Bi

You should use .NET Core, instead of .NET Framework or Xamarin, in the following 6 typical scenarios according to the documentation here.

根据此处的文档,在以下 6 种典型场景中,您应该使用 .NET Core,而不是 .NET Framework 或 Xamarin 。

1. Cross-Platform needs

Clearly, if your goal is to have an application (web/service) that should be able to run across platforms (Windows, Linux and MacOS), the best choice in the .NET ecosystem is to use .NET Core as its runtime (CoreCLR) and libraries are cross-platform. The other choice is to use the Mono Project.

Both choices are open source, but .NET Core is directly and officially supported by Microsoft and will have a heavy investment moving forward.

When using .NET Core across platforms, the best development experience exists on Windows with the Visual Studio IDE which supports many productivity features including project management, debugging, source control, refactoring, rich editing including Intellisense, testing and much more. But rich development is also supported using Visual Studio Code on Mac, Linux and Windows including intellisense and debugging. Even third party editors like Sublime, Emacs, VI and more work well and can get editor intellisense using the open source Omnisharp project.

2. Microservices

When you are building a microservices oriented system composed of multiple independent, dynamically scalable, stateful or stateless microservices, the great advantage that you have here is that you can use different technologies/frameworks/languages at a microservice level. That allows you to use the best approach and technology per micro areas in your system, so if you want to build very performant and scalable microservices, you should use .NET Core. Eventually, if you need to use any .NET Framework library that is not compatible with .NET Core, there's no issue, you can build that microservice with the .NET Framework and in the future you might be able to substitute it with the .NET Core.

The infrastructure platform you could use are many. Ideally, for large and complex microservice systems, you should use Azure Service Fabric. But for stateless microservices you can also use other products like Azure App Service or Azure Functions.

Note that as of June 2016, not every technology within Azure supports the .NET Core, but .NET Core support in Azure will be increasing dramatically now that .NET Core is RTM released.

3. Best performant and scalable systems

When your system needs the best possible performance and scalability so you get the best responsiveness no matter how many users you have, then is where .NET Core and ASP.NET Core really shine. The more you can do with the same amount of infrastructure/hardware, the richer the experience you'll have for your end users – at a lower cost.

The days of Moore's law performance improvements for single CPUs does not apply anymore; yet you need to do more while your system is growing and need higher scalability and performance for everyday' s more demanding users which are growing exponentially in numbers. You need to get more efficient, optimize everywhere, and scale better across clusters of machines, VMs and CPU cores, ultimately. It is not just a matter of user's satisfaction; it can also make a huge difference in cost/TCO. This is why it is important to strive for performance and scalability.

As mentioned, if you can isolate small pieces of your system as microservices or any other loosely-coupled approach, it'll be better as you'll be able to not just evolve each small piece/microservice independently and have a better long-term agility and maintenance, but also you'll be able to use any other technology at a microservice level if what you need to do is not compatible with .NET Core. And eventually you'd be able to refactor it and bring it to .NET Core when possible.

4. Command line style development for Mac, Linux or Windows.

This approach is optional when using .NET Core. You can also use the full Visual Studio IDE, of course. But if you are a developer that wants to develop with lightweight editors and heavy use of command line, .NET Core is designed for CLI. It provides simple command line tools available on all supported platforms, enabling developers to build and test applications with a minimal installation on developer, lab or production machines. Editors like Visual Studio Code use the same command line tools for their development experiences. And IDE's like Visual Studio use the same CLI tools but hide them behind a rich IDE experience. Developers can now choose the level they want to interact with the tool chain from CLI to editor to IDE.

5. Need side by side of .NET versions per application level.

If you want to be able to install applications with dependencies on different versions of frameworks in .NET, you need to use .NET Core which provides 100% side-by side as explained previously in this document.

6. Windows 10 UWP .NET apps.

1. 跨平台需求

显然,如果您的目标是拥有一个能够跨平台(Windows、Linux 和 MacOS)运行的应用程序(网络/服务),那么 .NET 生态系统中的最佳选择是使用 .NET Core 作为其运行时(CoreCLR ) 和库是跨平台的。另一种选择是使用 Mono 项目。

这两种选择都是开源的,但 .NET Core 得到了微软的直接和官方支持,并且将有大量投资向前推进。

跨平台使用 .NET Core 时,最好的开发体验存在于带有 Visual Studio IDE 的 Windows 上,Visual Studio IDE 支持许多生产力功能,包括项目管理、调试、源代码控制、重构、丰富的编辑(包括 Intellisense)、测试等等。但是,在 Mac、Linux 和 Windows 上使用 Visual Studio Code 也支持丰富的开发,包括智能感知和调试。即使是 Sublime、Emacs、VI 等第三方编辑器也能很好地工作,并且可以使用开源 Omnisharp 项目获得编辑器智能感知。

2. 微服务

当您正在构建由多个独立的、动态可扩展的、有状态或无状态的微服务组成的面向微服务的系统时,您在这里拥有的巨大优势是您可以在微服务级别使用不同的技术/框架/语言。这使您可以在系统中的每个微领域使用最佳方法和技术,因此如果您想构建非常高性能和可扩展的微服务,您应该使用 .NET Core。最终,如果您需要使用任何与 .NET Core 不兼容的 .NET Framework 库,没有问题,您可以使用 .NET Framework 构建该微服务,并且将来您可能可以用 .NET 替代它核。

您可以使用的基础设施平台有很多。理想情况下,对于大型复杂的微服务系统,应使用 Azure Service Fabric。但是对于无状态微服务,您还可以使用其他产品,例如 Azure 应用服务或 Azure Functions。

请注意,截至 2016 年 6 月,并非 Azure 中的所有技术都支持 .NET Core,但随着 .NET Core 发布 RTM,Azure 中的 .NET Core 支持将急剧增加。

3. 最佳性能和可扩展系统

当您的系统需要尽可能最佳的性能和可扩展性以便无论您拥有多少用户都能获得最佳响应能力时,那么 .NET Core 和 ASP.NET Core 就真正发挥了作用。使用相同数量的基础设施/硬件可以做的越多,最终用户的体验就越丰富 - 成本越低。

单 CPU 的摩尔定律性能改进时代不再适用;然而,您需要在系统不断增长的同时做更多的事情,并且需要更高的可扩展性和性能来满足每天数量呈指数增长的要求更高的用户。您最终需要提高效率,随处优化,并在机器、VM 和 CPU 内核的集群中更好地扩展。这不仅仅是用户满意的问题;它还可以在成本/TCO 方面产生巨大差异。这就是为什么努力提高性能和可扩展性很重要的原因。

如前所述,如果您可以将系统的小部分隔离为微服务或任何其他松散耦合的方法,那就更好了,因为您不仅能够独立地发展每个小部分/微服务,而且可以拥有更好的长期敏捷性和维护,但如果您需要做的事情与 .NET Core 不兼容,您也可以在微服务级别使用任何其他技术。最终,您将能够重构它并在可能的情况下将其引入 .NET Core。

4. Mac、Linux 或 Windows 的命令行风格开发。

使用 .NET Core 时,此方法是可选的。当然,您也可以使用完整的 Visual Studio IDE。但是,如果您是想要使用轻量级编辑器和大量使用命令行进行开发的开发人员,那么 .NET Core 就是为 CLI 设计的。它提供了在所有支持的平台上可用的简单命令行工具,使开发人员能够在开发人员、实验室或生产机器上以最少的安装来构建和测试应用程序。像 Visual Studio Code 这样的编辑器使用相同的命令行工具来获得他们的开发体验。IDE 就像 Visual Studio 一样使用相同的 CLI 工具,但将它们隐藏在丰富的 IDE 体验之后。开发人员现在可以选择他们想要与从 CLI 到编辑器再到 IDE 的工具链进行交互的级别。

5. 需要每个应用程序级别的 .NET 版本并排。

如果您希望能够在 .NET 中安装依赖于不同版本框架的应用程序,您需要使用 .NET Core,它提供 100% 并行,如本文档前面所述。

6. Windows 10 UWP .NET 应用程序。

In addition, you may also want to read:

此外,您可能还想阅读:

  1. When should I NOTuse .NET Core?
  2. When should I still use .NET Framework 4.x, instead of .NET Core?
  3. When should I use Xamarin, instead of .NET Core?
  1. 我什么时候应该使用 .NET Core?
  2. 我什么时候应该仍然使用 .NET Framework 4.x,而不是 .NET Core?
  3. 我什么时候应该使用 Xamarin 而不是 .NET Core?

回答by Nate Barbettini

This is how Microsoft explains it:

微软是这样解释的:

.NET Framework, .NET Core, Xamarin

.NET 框架、.NET 核心、Xamarin

.NET Frameworkis the "full" or "traditional" flavor of .NET that's distributed with Windows. Use this when you are building a desktop Windows or UWP app, or working with older ASP.NET 4.6+.

.NET Framework是随 Windows 分发的“完整”或“传统”风格的 .NET。在构建桌面 Windows 或 UWP 应用程序或使用较旧的 ASP.NET 4.6+ 时使用此选项。

.NET Coreis cross-platform .NET that runs on Windows, Mac, and Linux. Use this when you want to build console or web apps that can run on any platform, including inside Docker containers. This does not include UWP/desktop apps currently.

.NET Core是跨平台的 .NET,可在 Windows、Mac 和 Linux 上运行。当您想要构建可以在任何平台(包括 Docker 容器内)上运行的控制台或 Web 应用程序时,请使用此选项。目前这不包括 UWP/桌面应用程序。

Xamarinis used for building mobile apps that can run on iOS, Android, or Windows Phone devices.

Xamarin用于构建可在 iOS、Android 或 Windows Phone 设备上运行的移动应用程序。

Xamarin usually runs on top of Mono, which is a version of .NET that was built for cross-platform support before Microsoft decided to officially go cross-platform with .NET Core. Like Xamarin, the Unity platform also runs on top of Mono.

Xamarin 通常运行在Mono之上,Mono是一个 .NET 版本,在微软决定正式使用 .NET Core 跨平台之前,它是为跨平台支持而构建的。与 Xamarin 一样,Unity 平台也运行在 Mono 之上。



A common point of confusion is where ASP.NET Core fits in. ASP.NET Core can run on top of either .NET Framework (Windows) or .NET Core (cross-platform), as detailed in this answer: Difference between ASP.NET Core (.NET Core) and ASP.NET Core (.NET Framework)

一个常见的混淆点是 ASP.NET Core 适合的位置。 ASP.NET Core 可以在 .NET Framework (Windows) 或 .NET Core(跨平台)之上运行,如以下答案中所述:Difference between ASP。 NET Core (.NET Core) 和 ASP.NET Core (.NET Framework)

回答by logeshpalani98

You can refer in this line - Difference between ASP.NET Core (.NET Core) and ASP.NET Core (.NET Framework)

您可以参考这一行 - ASP.NET Core (.NET Core) 和 ASP.NET Core (.NET Framework) 之间的差异

.NET Framework, .NET Core, Xamarin

.NET 框架、.NET 核心、Xamarin

Xamarinis not a debate at all. When you want to build mobile (iOS, Android, and Windows Mobile) apps using C#, Xamarin is your only choice.

Xamarin根本不是辩论。当你想要使用 C# 构建移动(iOS、Android 和 Windows Mobile)应用程序时,Xamarin 是你唯一的选择。

The .NET Frameworksupports Windows and Web applications. Today, you can use Windows Forms, WPF, and UWP to build Windows applications in .NET Framework. ASP.NET MVC is used to build Web applications in .NET Framework.

.NET Framework支持 Windows 和 Web 应用程序。现在,您可以使用 Windows 窗体、WPF 和 UWP 在 .NET Framework 中构建 Windows 应用程序。ASP.NET MVC 用于在 .NET Framework 中构建 Web 应用程序。

.NET Coreis the new open-source and cross-platform framework to build applications for all operating system including Windows, Mac, and Linux. .NET Core supports UWP and ASP.NET Core only. UWP is used to build Windows 10 targets Windows and mobile applications. ASP.NET Core is used to build browser based web applications.

.NET Core是新的开源和跨平台框​​架,用于为所有操作系统(包括 Windows、Mac 和 Linux)构建应用程序。.NET Core 仅支持 UWP 和 ASP.NET Core。UWP 用于构建面向 Windows 和移动应用程序的 Windows 10。ASP.NET Core 用于构建基于浏览器的 Web 应用程序。

you want more details refer this links
https://blogs.msdn.microsoft.com/dotnet/2016/07/15/net-core-roadmap/https://docs.microsoft.com/en-us/dotnet/articles/standard/choosing-core-framework-server

您想了解更多详细信息,请参阅此链接
https://blogs.msdn.microsoft.com/dotnet/2016/07/15/net-core-roadmap/ https://docs.microsoft.com/en-us/dotnet/articles /标准/选择核心框架服务器

回答by Razib Hossain

  1. .NETis the Ecosystem based on c#language
  2. .NET Standardis Standard (in other words, specification) of .NETEcosystem .
  1. .NET是基于c#语言的生态系统
  2. .NET Standard.NET生态系统的标准(换言之,规范)。

.NetCore Class Library is built upon the .Net Standard. .NET Standard you can make only class-library project that cannot be executed standalone and should be referenced by another .NET Core or.NET Frameworkexecutable project.If you want to implement a library that is portable to the .Net Framework, .Net Coreand Xamarin, choose a .Net StandardLibrary

.Net核心类库建立在.Net 标准之上。.NET Standard 只能创建不能独立执行且应由另一个.NET Core 或.NET Framework可执行项目引用的类库项目。如果要实现可移植到.Net Framework的库,.Net CoreXamarin,选择一个.Net 标准

  1. .NET Frameworkis a framework based on .NETand it supports Windows and Web applications
  1. .NET Framework是一个基于.NET的框架,它支持 Windows 和 Web 应用程序

(You can make executable project (like Console application, or ASP.NET application) with .NET Framework

(您可以使用 .NET Framework 制作可执行项目(如 Console 应用程序或 ASP.NET 应用程序)

  1. ASP.NETis a web application development technology which is built over the .NET Framework
  2. .NET Corealso a framework based on .NET.
  1. ASP.NET是一种基于.NET Framework构建的 Web 应用程序开发技术
  2. .NET Core也是一个基于.NET的框架。

It is the new open-source and cross-platform framework to build applications for all operating system including Windows, Mac, and Linux.

它是新的开源和跨平台框​​架,可为所有操作系统(包括 Windows、Mac 和 Linux)构建应用程序。

  1. Xamarinis a framework to develop a cross platform mobile application(iOS, Android, and Windows Mobile) using C#
  1. Xamarin是一个使用C#开发跨平台移动应用程序(iOS、Android 和 Windows Mobile)的框架

Implementation support of .NET Standard[blue]and minimum viable platform for full support of .NET Standard (latest: [https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support])

.NET Standard [蓝色] 的实现支持和完全支持 .NET Standard 的最小可行平台(最新:[ https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-支持])

回答by yanlend

.NET 5will be a unified version of all .NET variants coming in November 2020, so there will be no need to choose between variants anymore. enter image description here

.NET 5将成为 2020 年 11 月推出的所有 .NET 变体的统一版本,因此不再需要在变体之间进行选择。 在此处输入图片说明

回答by Marto99

.NET Core is the current version of .NET that you should be using right now (more features , fixed bugs , etc.)

.NET Core 是您现在应该使用的 .NET 的当前版本(更多功能、修复错误等)

Xamarin is a platform that provides solutions for cross platform mobile problems coded in C# , so that you don't need to use Swift separately for IOS and the same goes for Android.

Xamarin 是一个为跨平台移动问题提供解决方案的平台,使用 C# 编码,因此您无需为 IOS 单独使用 Swift,Android 也是如此。

回答by user10868910

Xamarin is used for phone applications (both IOS/Android). The .NET Core is used for designing Web applications that can work on both Apache and IIS.

Xamarin 用于手机应用程序(IOS/Android)。.NET Core 用于设计可在 Apache 和 IIS 上运行的 Web 应用程序。

That is the difference in two sentences.

这就是两句话的区别。

回答by yangching

updated on May 2019

2019 年 5 月更新

you should use .Net Core 3.0 and later on upgrade to its next version .Net 5, all you need is just one unified platform .Net5

您应该使用 .Net Core 3.0 及更高版本升级到其下一个版本 .Net 5,您只需要一个统一平台 .Net5

There will be just one .NET going forward, and you will be able to use it to target >Windows, Linux, macOS, iOS, Android, tvOS, watchOS and WebAssembly and more. https://devblogs.microsoft.com/dotnet/introducing-net-5/

未来将只有一个 .NET,您将能够使用它来针对 >Windows、Linux、macOS、iOS、Android、tvOS、watchOS 和 WebAssembly 等等。 https://devblogs.microsoft.com/dotnet/introducing-net-5/