.NET 体系结构组件.NET architectural components

.NET 应用开发用于并运行于一个或多个 .NET 实现 。A .NET app is developed for and runs in one or more implementations of .NET. .NET 实现包括 .NET Framework、.NET Core 和 Mono。Implementations of .NET include the .NET Framework, .NET Core, and Mono. .NET 的所有实现都有一个名为 .NET Standard 的通用 API 规范。There is an API specification common to all implementations of .NET that's called the .NET Standard. 本文简要介绍了每个概念。This article gives a brief introduction to each of these concepts.

.NET Standard.NET Standard

.NET Standard 是一组由 .NET 实现的基类库实现的 API。The .NET Standard is a set of APIs that are implemented by the Base Class Library of a .NET implementation. 更正式地说,它是构成协定统一集(这些协定是编写代码的依据)的特定 .NET API 组。More formally, it's a specification of .NET APIs that make up a uniform set of contracts that you compile your code against. 这些协定在每个 .NET 实现中实现。These contracts are implemented in each .NET implementation. 这可实现不同 .NET 实现间的可移植性,有效地使代码可在任何位置运行。This enables portability across different .NET implementations, effectively allowing your code to run everywhere.

.NET Standard 也是一个目标框架The .NET Standard is also a target framework. 如果代码面向 .NET Standard 版本,则它可在支持该 .NET Standard 版本的任何 .NET 实现上运行。If your code targets a version of the .NET Standard, it can run on any .NET implementation which supports that version of the .NET Standard.

若要详细了解 .NET Standard 以及如何将其作为目标,请参阅 .NET Standard 主题。To learn more about the .NET Standard and how to target it, see the .NET Standard topic.

.NET 实现.NET implementations

.NET 的每个实现都具有以下组件:Each implementation of .NET includes the following components:

  • 一个或多个运行时。One or more runtimes. 示例:CLR 用于 .NET Framework,CoreCLR 和 CoreRT 用于 .NET Core。Examples: CLR for .NET Framework, CoreCLR and CoreRT for .NET Core.
  • 实现 .NET Standard 并且可实现其他 API 的类库。A class library that implements the .NET Standard and may implement additional APIs. 示例:.NET Framework 基类库、.NET Core 基类库。Examples: .NET Framework Base Class Library, .NET Core Base Class Library.
  • 可选择包含一个或多个应用程序框架。Optionally, one or more application frameworks. 示例:ASP.NETWindows 窗体Windows Presentation Foundation (WPF) 包含在 .NET Framework 和 .NET Core 中。Examples: ASP.NET, Windows Forms, and Windows Presentation Foundation (WPF) are included in the .NET Framework and .NET Core.
  • 可包含开发工具。Optionally, development tools. 某些开发工具在多个实现之间共享。Some development tools are shared among multiple implementations.

Microsoft 积极开发和维护的主要 .NET 实现有 4 个:.NET Core、.NET Framework、Mono 和 UWP。There are four primary .NET implementations that Microsoft actively develops and maintains: .NET Core, .NET Framework, Mono, and UWP.

.NET Core.NET Core

.NET Core 是 .NET 的跨平台实现,专用于处理大规模的服务器和云工作负荷。.NET Core is a cross-platform implementation of .NET and designed to handle server and cloud workloads at scale. 可在 Windows、macOS 和 Linux 上运行。It runs on Windows, macOS, and Linux. 它实现 .NET Standard,因此面向 .NET Standard 的代码都可在 .NET Core 上运行。It implements the .NET Standard, so code that targets the .NET Standard can run on .NET Core. ASP.NET CoreWindows 窗体Windows Presentation Foundation (WPF) 都在 .NET Core 上运行。ASP.NET Core, Windows Forms, and Windows Presentation Foundation (WPF) all run on .NET Core.

要了解有关 .NET Core 的详细信息,请参阅 .NET Core 指南为服务器应用选择 .NET Core 或 .NET FrameworkTo learn more about .NET Core, see the .NET Core Guide and Choosing between .NET Core and .NET Framework for server apps.

.NET Framework.NET Framework

.Net Framework 是自 2002 年起就已存在的原始 .NET 实现。The.NET Framework is the original .NET implementation that has existed since 2002. 它是当前 .NET 开发人员经常使用的 .NET Framework。It's the same .NET Framework that existing .NET developers have always used. 4.5 版以及更高版本实现 .NET Standard,因此面向 .NET Standard 的代码都可在这些版本的 .NET Framework 上运行。Versions 4.5 and later implement the .NET Standard, so code that targets the .NET Standard can run on those versions of the .NET Framework. 它还包含一些特定于 Windows 的 API,如通过 Windows 窗体和 WPF 进行 Windows 桌面开发的 API。It contains additional Windows-specific APIs, such as APIs for Windows desktop development with Windows Forms and WPF. .NET Framework 非常适合用于生成 Windows 桌面应用程序。The .NET Framework is optimized for building Windows desktop applications.

若要了解有关 .NET Framework 的详细信息,请参阅 .NET Framework 指南To learn more about the .NET Framework, see the .NET Framework Guide.


Mono 是主要在需要小型运行时使用的 .NET 实现。Mono is a .NET implementation that is mainly used when a small runtime is required. 它是在 Android、macOS、iOS、tvOS 和 watchOS 上驱动 Xamarin 应用程序的运行时,且主要针对小内存占用。It is the runtime that powers Xamarin applications on Android, macOS, iOS, tvOS, and watchOS and is focused primarily on a small footprint. Mono 还支持使用 Unity 引擎生成的游戏。Mono also powers games built using the Unity engine.

它支持所有当前已发布的 .NET Standard 版本。It supports all of the currently published .NET Standard versions.

以前,Mono 实现更大的 .NET Framework API 并模拟一些 Unix 上最常用的功能。Historically, Mono implemented the larger API of the .NET Framework and emulated some of the most popular capabilities on Unix. 有时使用它运行依赖 Unix 上的这些功能的 .NET 应用程序。It is sometimes used to run .NET applications that rely on those capabilities on Unix.

Mono 通常与实时编译器一起使用,但它也提供在 iOS 之类的平台使用的完整静态编译器(预先编译)。Mono is typically used with a just-in-time compiler, but it also features a full static compiler (ahead-of-time compilation) that is used on platforms like iOS.

若要了解有关 Mono 的详细信息,请参阅 Mono 文档To learn more about Mono, see the Mono documentation.

通用 Windows 平台 (UWP)Universal Windows Platform (UWP)

UWP 是用于为物联网 (IoT) 生成新式触控 Windows 应用程序和软件的 .NET 实现。UWP is an implementation of .NET that is used for building modern, touch-enabled Windows applications and software for the Internet of Things (IoT). 它旨在统一可能想要以其为目标的不同类型的设备,包括电脑、平板电脑、平板手机、电话,甚至 Xbox。It's designed to unify the different types of devices that you may want to target, including PCs, tablets, phablets, phones, and even the Xbox. UWP 提供许多服务,如集中式应用商店、执行环境 (AppContainer) 和一组 Windows API(用于代替 Win32 (WinRT))。UWP provides many services, such as a centralized app store, an execution environment (AppContainer), and a set of Windows APIs to use instead of Win32 (WinRT). 应用可采用 C++、C#、Visual Basic 和 JavaScript 编写。Apps can be written in C++, C#, Visual Basic, and JavaScript. 使用 C# 和 Visual Basic 时,.NET API 由 .NET Core 提供。When using C# and Visual Basic, the .NET APIs are provided by .NET Core.

若要详细了解 UWP,请参阅通用 Windows 平台简介To learn more about UWP, see Intro to the Universal Windows Platform.

.NET 运行时.NET runtimes

运行时是用于托管程序的执行环境。A runtime is the execution environment for a managed program. 操作系统属于运行时环境,但不属于 .NET 运行时。The OS is part of the runtime environment but is not part of the .NET runtime. 下面是 .NET 运行时的一些示例:Here are some examples of .NET runtimes:

  • .NET Framework 公共语言运行时 (CLR)Common Language Runtime (CLR) for the .NET Framework
  • .NET Core 核心公共语言运行时 (CoreCLR)Core Common Language Runtime (CoreCLR) for .NET Core
  • 适用于通用 Windows 平台的 .NET Native.NET Native for Universal Windows Platform
  • 用于 Xamarin.iOS、Xamarin.Android、Xamarin.Mac 和 Mono 桌面框架的 Mono 运行时The Mono runtime for Xamarin.iOS, Xamarin.Android, Xamarin.Mac, and the Mono desktop framework

.NET 工具和常见基础结构.NET tooling and common infrastructure

可访问一整套适用于每种 .NET 实现的工具和基础结构组件。You have access to an extensive set of tools and infrastructure components that work with every implementation of .NET. 包括(但不限于)以下几种:These include, but are not limited to the following:

  • .NET 语言及其编译器The .NET languages and their compilers
  • .NET 项目系统(基于 .csproj .vbproj 和 .fsproj 文件)The .NET project system (based on .csproj, .vbproj, and .fsproj files)
  • MSBuild(用于生成项目的生成引擎)MSBuild, the build engine used to build projects
  • NuGet(适用于.NET 的 Microsoft 程序包管理器)NuGet, Microsoft's package manager for .NET
  • 开放源生成业务流程工具,例如 CAKEFAKEOpen-source build orchestration tools, such as CAKE and FAKE

适用标准Applicable standards

C# 语言和公共语言基础结构 (CLI) 规范通过 Ecma International® 进行标准化。The C# Language and the Common Language Infrastructure (CLI) specifications are standardized through Ecma International®. 这些标准的第一版已于 2001 年 12 月由 Ecma 发布。The first editions of these standards were published by Ecma in December 2001.

这些标准的后续版本由编程委员技术委员会 (TC49) 的 TC49-TG2 (C#) 和 TC49-TG3 (CLI) 任务组编制,被 Ecma General Assembly 采纳,随后通过 ISO 快速跟踪流程被 ISO/IEC JTC 1 采纳。Subsequent revisions to the standards have been developed by the TC49-TG2 (C#) and TC49-TG3 (CLI) task groups within the Programming Languages Technical Committee (TC49), and adopted by the Ecma General Assembly and subsequently by ISO/IEC JTC 1 via the ISO Fast-Track process.

最新标准Latest standards

以下官方 Ecma 文档可用于 C#CLI (TR-84):The following official Ecma documents are available for C# and the CLI (TR-84):

  • C# 语言标准(版本 5.0)ECMA-334.pdfThe C# Language Standard (version 5.0): ECMA-334.pdf
  • 公共语言基础结构:提供 pdfzip 形式。The Common Language Infrastructure: This is available in pdf form and zip form.
  • 派生自分区 IV XML 文件的信息:提供 pdfzip 格式。Information Derived from the Partition IV XML File: This is available in pdf and zip formats.

官方 ISO/IEC 文档可从 ISO/IEC 公开标准页获取。The official ISO/IEC documents are available from the ISO/IEC Publicly Available Standards page. 以下链接可从该页面直接获得:These links are direct from that page:

  • 信息技术 - 编程语言 - C#ISO/IEC 23270:2018Information technology - Programming languages - C#: ISO/IEC 23270:2018
  • 信息技术 - 公共语言基础结构 (CLI) 分区 I 到 VIISO/IEC 23271:2012Information technology — Common Language Infrastructure (CLI) Partitions I to VI: ISO/IEC 23271:2012
  • 信息技术 - 公共语言基础结构 (CLI) - 有关派生自分区 IV XML 文件的信息的技术报告ISO/IEC TR 23272:2011Information technology — Common Language Infrastructure (CLI) — Technical Report on Information Derived from Partition IV XML File: ISO/IEC TR 23272:2011

另请参阅See also