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

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

Microsoft 现在拥有 .NET Core、.NET Framework 和 Xamarin (Mono)。

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

微软是这样解释的:

.NET Framework 是 "full" 或 "traditional" 风格的 .NET,随 Windows 一起分发。当您构建桌面 Windows 或 UWP 应用程序,或使用较旧的 ASP.NET 4.6+ 时,请使用它。

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

Xamarin 用于构建可以 运行 on iOS、Android 或 Windows Phone 台设备。

Xamarin 通常 运行s 在 Mono 之上,后者是在 Microsoft 决定正式跨平台之前为跨平台支持而构建的 .NET 版本- .NET Core 平台。与 Xamarin 一样,Unity 平台也在 Mono 之上 运行。


一个常见的混淆点是 ASP.NET Core 适合的位置。ASP.NET Core 可以 运行 在 .NET Framework (Windows) 或 .NET 之上核心(跨平台),详见此答案:Difference between ASP.NET Core (.NET Core) and ASP.NET Core (.NET Framework)

根据文档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. When should I NOT use .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?

你可以参考这一行 -

Xamarin 根本不是争论。如果您想使用 C# 构建移动(iOS、Android 和 Windows 移动)应用程序,Xamarin 是您唯一的选择。

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

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

您需要更多详细信息,请参阅此链接
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

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

Xamarin 是一个为用 C# 编写的跨平台移动问题提供解决方案的平台,因此您不需要为 IOS 单独使用 Swift,[=14 也一样=].

  1. .NET 是基于 c# 语言
  2. 的生态系统
  3. .NET Standard.NET 生态系统的标准(换句话说,规范)。

.Net Core 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 Framework executable project.If you want to implement a library that is portable to the .Net Framework, .Net Core and Xamarin, choose a .Net Standard Library

  1. .NET Framework是基于.NET的框架,支持Windows和Web应用

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

  1. ASP.NET 是一种基于 .NET Framework
  2. 的 Web 应用程序开发技术
  3. .NET Core也是一个基于.NET.
  4. 的框架

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

  1. Xamarin 是一个用于开发跨平台移动应用程序的框架(iOS、Android 和 Windows移动) 使用 C#

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 5 将是 2020 年 11 月推出的所有 .NET 变体的统一版本,因此无需再在变体之间进行选择。

Xamarin 用于 phone 个应用程序(均为 IOS/Android)。 .NET Core 用于设计可以同时在 Apache 和 IIS 上运行的 Web 应用程序。

也就是两句话的区别

  • .NET Framework - Windows Microsoft 对 .NET 的唯一遗留实现。 2002 年推出,正在逐步淘汰。
  • .NET 5(.NET Core 3.1 的后继者)- .NET Framework 的现代重新实现旨在取代它,支持 Windows、macOS 和 Linux。 2016 年推出,后续版本可能吸收 Xamarin
  • Xamarin - Mono 与非 windows OS 的平台绑定以及为移动应用程序开发量身定制的 API 和工具(iOS、Android 和最近的桌面). 2012 年推出。Mono 是由社区开发的 .NET 的非 Microsoft 实现,并于 2000 年代初推出并与 .NET Framework 竞争。

.Net Frame 工作用于 windows 基础应用程序。 .Net 核心框架工作用于跨平台基础应用程序。 Xamarin 框架工作用于移动应用程序开发。

  1. .Net Framework(最新版本 4.8)仅支持 windows platform.Means 您的桌面应用程序只能在 Windows 上运行。并且 Web 应用程序只能托管在 Windows Server/Windows OS

  2. .Net Core(从.net core 1, 2, 2.1, 3.1, Latest version 5开始)是交叉的 平台.(windows , Linux , Mac).

  3. 另一方面,Xamarin 支持移动平台。 (Android 和 IOS)。用于开发移动应用程序。

[截至 2022 年 2 月]

.NET 框架

  • 专有框架
  • 主要用于WindowsOS
  • 4.8 版是最终版本。
  • 对它的支持可能会以 Windows 10(以及其他 server siblings
  • 结束

.NET (以前的 .NET Core)

  • 免费和open-source
  • Cross-platform
  • .NET Framework
  • 的继承者
  • 目前.NET 6是LTS版本

Xamarin

  • 免费和open-source
  • 用于使用 .NET 和 C# 构建 Android 和 iOS 应用
  • .NET 的一部分