.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 5 (和 .NET Core) 和 Mono。Implementations of .NET include the .NET Framework, .NET 5 (and .NET Core), and Mono. 有多個 .NET (稱為 .NET Standard)的常見 API 規格。There is an API specification common to multiple implementations of .NET that's called .NET Standard. 本文提供上述每個概念的簡介。This article gives a brief introduction to each of these concepts.

.NET Standard.NET Standard

.NET Standard 是由 .NET 實作為基礎類別庫所執行的一組 Api。.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 multiple .NET implementations.

.NET Standard 是 目標 framework.NET Standard is a target framework. 如果您的程式碼是以 .NET Standard 版本為目標,則可以在支援該 .NET Standard 版本的任何 .NET 執行上執行。If your code targets a version of .NET Standard, it can run on any .NET implementation that supports that version of .NET Standard.

.NET Standard 的建立是為了讓不同的 .NET 執行都能移植,但現在 .NET 5 提供了更好的方法,可跨多個平臺和工作負載共用程式碼。.NET Standard was created to enable portability across different .NET implementations, but now .NET 5 offers a better way to share code across multiple platforms and workloads. 如需詳細資訊,請參閱 .net 5 和 .Net StandardFor more information, see .NET 5 and .NET Standard.

.NET 實作.NET implementations

.NET 的每項實作包括下列元件:Each implementation of .NET includes the following components:

  • 一或多個執行階段。One or more runtimes. 範例: .NET Framework CLR、.NET 5 CLR。Examples: .NET Framework CLR, .NET 5 CLR.
  • 類別庫。A class library. 範例: .NET Framework 基類庫、.NET 5 基類程式庫。Examples: .NET Framework Base Class Library, .NET 5 Base Class Library.
  • (選擇性) 一或多個應用程式架構。Optionally, one or more application frameworks. 範例: ASP.NETWindows Formswindows Presentation Foundation (WPF) 包含在 .net Framework 和 .net 5 中。Examples: ASP.NET, Windows Forms, and Windows Presentation Foundation (WPF) are included in the .NET Framework and .NET 5.
  • (選擇性) 開發工具。Optionally, development tools. 某些開發工具可在多個實作之間共用。Some development tools are shared among multiple implementations.

有四個 Microsoft 支援的 .NET 實現:There are four .NET implementations that Microsoft supports:

  • .NET 5 (和 .NET Core) 和更新版本.NET 5 (and .NET Core) and later versions
  • .NET Framework.NET Framework
  • MonoMono
  • UWPUWP

.NET 5 現在是主要的實作為進行中開發的重點。.NET 5 is now the primary implementation, the one that is the focus of ongoing development. .NET 5 建基於單一程式碼基底,可支援多個平臺和許多工作負載,例如 Windows 傳統型應用程式和跨平臺主控台應用程式、雲端服務和網站。.NET 5 is built on a single code base that supports multiple platforms and many workloads, such as Windows desktop apps and cross-platform console apps, cloud services, and websites.

.NET 5.NET 5

.NET 5 是 .NET 的跨平臺執行,其設計目的是要大規模處理伺服器和雲端工作負載。.NET 5 is a cross-platform implementation of .NET that is designed to handle server and cloud workloads at scale. 也支援其他工作負載,包括桌面應用程式。It also supports other workloads, including desktop apps. 它會在 Windows、macOS 和 Linux 上執行。It runs on Windows, macOS, and Linux. 它會實作為 .NET 標準,因此以 .NET Standard 為目標的程式碼可以在 .NET 5 上執行。It implements .NET Standard, so code that targets .NET Standard can run on .NET 5. ASP.NET CoreWindows FormsWindows Presentation Foundation (WPF) 全都在 .net 5 上執行。ASP.NET Core, Windows Forms, and Windows Presentation Foundation (WPF) all run on .NET 5.

如需詳細資訊,請參閱下列資源:For more information, see the following resources:

.NET Framework.NET Framework

.NET Framework 是自2002以來已存在的原始 .NET 執行。.NET Framework is the original .NET implementation that has existed since 2002. 4.5 版和更新版本會實行 .NET Standard,因此以 .NET Standard 為目標的程式碼可以在這些版本的 .NET Framework 上執行。Versions 4.5 and later implement .NET Standard, so code that targets .NET Standard can run on those versions of .NET Framework. 它包含其他 Windows 特定的 API,例如,使用 Windows Form 和 WPF 進行適用於 Windows 桌面開發的 API。It contains additional Windows-specific APIs, such as APIs for Windows desktop development with Windows Forms and WPF. .NET Framework 最適合用來建置 Windows 傳統型應用程式。.NET Framework is optimized for building Windows desktop applications.

如需詳細資訊,請參閱 .Net Framework 指南For more information, see the .NET Framework guide.

MonoMono

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 通常可搭配 Just-In-Time 編譯器使用,但也提供適用於 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 檔For more information, 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, phones, and even the Xbox. UWP 提供許多服務 (例如集中式應用程式存放區)、一個執行環境 (AppContainer),以及用來取代 Win32 (WinRT) 的一組 Windows API。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.

如需詳細資訊,請參閱 通用 Windows 平臺簡介For more information, see Introduction to the Universal Windows Platform.

.NET 執行階段.NET runtimes

執行階段是受管理程式的執行環境。A runtime is the execution environment for a managed program. OS 是執行階段環境的一部分,但不是 .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 的 Common Language Runtime (CLR) Common Language Runtime (CLR) for .NET Framework
  • 適用于 .NET 5 的 Common Language Runtime (CLR) Common Language Runtime (CLR) for .NET 5
  • 適用於通用 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 tools and components include:

  • .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

如需詳細資訊,請參閱 工具和生產力For more information, see Tools and productivity.

適用標準Applicable standards

C # 語言和 Common Language 基礎結構 (CLI) 規格是透過Ecma 國際 ® 標準化。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-TG2 (c # ) 和 TC49-TG3 (CLI) 在程式設計語言中的工作群組 (TC49) ,然後由 Ecma 一般元件所採用,之後透過 Iso Fast-Track 程式來採用 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):

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