.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 實作有一個通用的 API 規格,稱為 .NET Standard。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 是一組 API,由 .NET 實作的基底類別庫所實作。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 也是目標 FrameworkThe .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. 例如:適用於 .NET Framework 的 CLR、適用於 .NET Core 的 CoreCLR 和 CoreRT。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 FormsWindows Presentation Foundation (WPF) 會包含在 .NET Framework 中。Examples: ASP.NET, Windows Forms, and Windows Presentation Foundation (WPF) are included in the .NET Framework.
  • (選擇性) 開發工具。Optionally, development tools. 某些開發工具可在多個實作之間共用。Some development tools are shared among multiple implementations.

Microsoft 會主動開發和維護的主要 .NET 實作有四個︰.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 Core 會在 .NET Core 上執行。ASP.NET Core runs 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 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 傳統型應用程式。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.

MonoMono

Mono 是需要小型執行階段時主要使用的 .NET 實作。Mono is a .NET implementation that is mainly used when a small runtime is required. 它是支援 Android、Mac、iOS、tvOS 和 watchOS 版 Xamarin 應用程式的執行階段,主要著重於較小的使用量。It is the runtime that powers Xamarin applications on Android, Mac, 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,請參閱 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),以及用來取代 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#、VB.NET 和 JavaScript 來撰寫應用程式。Apps can be written in C++, C#, VB.NET, and JavaScript. 使用 C# 和 VB.NET 時,.NET API 是由 .NET Core 所提供。When using C# and VB.NET, 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. 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 the .NET Framework
  • 適用於 .NET Core 的 Core Common Language Runtime (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

另請參閱See also