.NET Framework 入门Get started with the .NET Framework

.NET Framework 是管理面向 .NET Framework 的应用的运行时执行环境。The .NET Framework is a runtime execution environment that manages apps that target the .NET Framework. 它包括公共语言运行时(提供内存管理和其他系统服务)和一个全面的类库(使程序员能利用强大可靠的代码实现所有主要领域的应用开发)。It consists of the common language runtime, which provides memory management and other system services, and an extensive class library, which enables programmers to take advantage of robust, reliable code for all major areas of app development.


.NET Framework 仅适用于 Windows 系统。The .NET Framework is available on Windows systems only. 可以使用 .NET Core 在 Windows、MacOS 和 Linux 上运行应用。You can use .NET Core to run apps on Windows, MacOS, and Linux.

什么是 .NET Framework?What is the .NET Framework?

.NET Framework 是 Windows 的托管执行环境,可为其运行的应用提供各种服务。The .NET Framework is a managed execution environment for Windows that provides a variety of services to its running apps. 它包括两个主要组件:公共语言运行时 (CLR),它是处理运行应用的执行引擎;.NET Framework 类库,它提供开发人员可从其自己的应用中调用的已测试、可重用代码库。It consists of two major components: the common language runtime (CLR), which is the execution engine that handles running apps, and the .NET Framework Class Library, which provides a library of tested, reusable code that developers can call from their own apps. .NET Framework 提供的用于运行应用的服务包括:The services that the .NET Framework provides to running apps include the following:

  • 内存管理。Memory management. 在许多编程语言中,程序员负责分配和释放内存并处理对象生存期。In many programming languages, programmers are responsible for allocating and releasing memory and for handling object lifetimes. 在 .NET Framework 应用中,CLR 代表应用提供这些服务。In .NET Framework apps, the CLR provides these services on behalf of the app.

  • 常规类型系统。A common type system. 在传统编程语言中,基本类型由编译器定义,这将使跨语言互操作性复杂化。In traditional programming languages, basic types are defined by the compiler, which complicates cross-language interoperability. 在 .NET Framework 中,基本类型由 .NET Framework 类型系统定义,并且是面向 .NET Framework 的所有语言所共有的。In the .NET Framework, basic types are defined by the .NET Framework type system and are common to all languages that target the .NET Framework.

  • 一个全面的类库。An extensive class library. 处理常见的低级编程操作时,程序员可通过 .NET Framework 类库使用类型及其成员的易访问库,而不必编写大量代码。Instead of having to write vast amounts of code to handle common low-level programming operations, programmers use a readily accessible library of types and their members from the .NET Framework Class Library.

  • 开发框架和技术。Development frameworks and technologies. .NET Framework 包括用于特定区域应用开发的库,如用于 Web 应用的 ASP.NET,用于数据访问的 ADO.NET,用于面向服务的应用的 Windows Communication Foundation 以及用于 Windows 桌面应用的 Windows Presentation Foundation。The .NET Framework includes libraries for specific areas of app development, such as ASP.NET for web apps, ADO.NET for data access, Windows Communication Foundation for service-oriented apps, and Windows Presentation Foundation for Windows desktop apps.

  • 语言互操作性。Language interoperability. 面向 .NET Framework 的语言编译器发出名为公共中间语言 (CIL) 的中间代码,反过来,通过公共语言运行时在运行时进行编译。Language compilers that target the .NET Framework emit an intermediate code named Common Intermediate Language (CIL), which, in turn, is compiled at runtime by the common language runtime. 借助此功能,使用某种语言编写的例程可由另一种语言访问,程序员可以专注于使用其首选语言创建应用。With this feature, routines written in one language are accessible to other languages, and programmers focus on creating apps in their preferred languages.

  • 版本兼容性。Version compatibility. 除少数例外,使用特定版本的 .NET Framework 开发的应用无需在更高版本中修改即可运行。With rare exceptions, apps that are developed by using a particular version of the .NET Framework run without modification on a later version.

  • 并行执行。Side-by-side execution. 通过允许同一台计算机上存在公共语言运行时的多个版本,.NET Framework 可帮助解决版本冲突。The .NET Framework helps resolve version conflicts by allowing multiple versions of the common language runtime to exist on the same computer. 这意味着应用的多个版本可以共存,并且应用可在构建它的 .NET Framework 版本上运行。This means that multiple versions of apps can coexist and that an app can run on the version of the .NET Framework with which it was built. 并行执行适用于 .NET Framework 版本组 1.0/1.1、2.0/3.0/3.5 和 4/4.5.x/4.6.x/4.7.x/4.8。Side-by-side execution applies to the .NET Framework version groups 1.0/1.1, 2.0/3.0/3.5, and 4/4.5.x/4.6.x/4.7.x/4.8.

  • 多定向。Multitargeting. 通过面向 .NET Standard,开发人员可创建适用于该标准版本支持的多种 .NET Framework 平台的类库。By targeting .NET Standard, developers create class libraries that work on multiple .NET Framework platforms supported by that version of the standard. 例如,面向 .NET Framework 4.6.1、NET Core 2.0 和 UWP 10.0.16299 的应用可以使用面向 .NET Standard 2.0 的库。For example, libraries that target the .NET Standard 2.0 can be used by apps that target the .NET Framework 4.6.1, .NET Core 2.0, and UWP 10.0.16299.

面向用户的 .NET FrameworkThe .NET Framework for users

如果你不开发 .NET Framework 应用,而只需要使用它们,则不需要掌握有关 .NET Framework 或其操作的特定知识。If you don't develop .NET Framework apps, but you use them, you aren't required to have specific knowledge about the .NET Framework or its operation. 大多数情况下,.NET Framework 对用户是完全透明的。For the most part, the .NET Framework is completely transparent to users.

如果你使用的是 Windows 操作系统,则你的计算机上可能已安装 .NET Framework。If you're using the Windows operating system, the .NET Framework may already be installed on your computer. 此外,如果安装需要 .NET Framework 的应用,则应用的安装程序可能会在你的计算机上安装特定版本的 .NET Framework。In addition, if you install an app that requires the .NET Framework, the app's setup program might install a specific version of the .NET Framework on your computer. 在某些情况下,可能会显示一个要求你安装 .NET Framework 的对话框。In some cases, you may see a dialog box that asks you to install the .NET Framework. 如果在该对话框出现时刚尝试过运行应用,并且计算机可以访问 Internet,则可以转到一个可安装缺少的 .NET Framework 版本的网页。If you've just tried to run an app when this dialog box appears and if your computer has Internet access, you can go to a webpage that lets you install the missing version of the .NET Framework. 有关详细信息,请参阅安装指南For more information, see the Installation guide.

一般而言,不应卸载计算机上已安装的 .NET Framework 版本。In general, you shouldn't uninstall versions of the .NET Framework that are installed on your computer. 主要有两个原因:There are two reasons for this:

  • 如果使用的应用依赖于特定版本的 .NET Framework,则该版本一旦删除,应用就会暂停。If an app that you use depends on a specific version of the .NET Framework, that app may break if that version is removed.

  • 一些 .NET Framework 版本是早期版本的就地更新版。Some versions of the .NET Framework are in-place updates to earlier versions. 例如,.NET Framework 3.5 是版本 2.0 的就地更新版,而 .NET Framework 4.8 是版本 4 到版本 4.7.2 的就地更新版。For example, the .NET Framework 3.5 is an in-place update to version 2.0, and the .NET Framework 4.8 is an in-place update to versions 4 through 4.7.2. 有关详细信息,请参见 .NET Framework 版本和依赖关系For more information, see .NET Framework Versions and Dependencies.

在 Windows 8 之前版本的 Windows 上,如果选择删除 .NET Framework,请始终通过“控制面板”的“程序及功能”进行卸载。 On Windows versions before Windows 8, if you do choose to remove the .NET Framework, always use Programs and Features from Control Panel to uninstall it. 请勿手动删除某个版本的 .NET Framework。Never remove a version of the .NET Framework manually. 在 Windows 8 和更高版本的操作系统上,.NET Framework 是一个操作系统组件,不能单独卸载。On Windows 8 and above, the .NET Framework is an operating system component and cannot be independently uninstalled.

请注意,一台计算机上可同时存在多个 .NET Framework 版本。Note that multiple versions of the .NET Framework can coexist on a single computer at the same time. 这意味着,你不必卸载旧版本即可安装更新版本。This means that you don't have to uninstall previous versions in order to install a later version.

面向开发人员的 .NET FrameworkThe .NET Framework for developers

如果你是开发人员,可选择任何支持 .NET Framework 的编程语言来创建应用。If you're a developer, choose any programming language that supports the .NET Framework to create your apps. 由于 .NET Framework 提供了语言独立性和互操作性,因此无论开发时使用何种语言,你都可以与其他 .NET Framework 应用和组件进行交互。Because the .NET Framework provides language independence and interoperability, you interact with other .NET Framework apps and components regardless of the language with which they were developed.

若要开发 .NET Framework 应用或组件,请执行以下操作:To develop .NET Framework apps or components, do the following:

  1. 如果未在操作系统上预安装 .NET Framework,请安装应用所面向的 .NET Framework 版本。If it's not preinstalled on your operating system, install the version of the .NET Framework that your app will target. 最新生产版本是 .NET Framework 4.8。The most recent production version is the .NET Framework 4.8. 此版本预安装在 Windows 10 2019 年 5 月更新中,并可下载到旧版 Windows 操作系统中。It is preinstalled on Windows 10 May 2019 Update, and it is available for download on earlier versions of the Windows operating system. 有关 .NET Framework 系统要求,请参阅系统要求For .NET Framework system requirements, see System Requirements. 有关安装其他版本的 .NET Framework 的信息,请参阅安装指南For information on installing other versions of the .NET Framework, see Installation Guide. 其他 .NET Framework 包为带外发布,这意味着这些包在滚动基础上发布,没有任何定期或计划的发布周期。Additional .NET Framework packages are released out of band, which means that they're released on a rolling basis outside of any regular or scheduled release cycle. 有关这些包的信息,请参阅 .NET Framework 和带外版本For information about these packages, see The .NET Framework and Out-of-Band Releases.

  2. 选择要用于开发应用的 .NET Framework 所支持的语言。Select the language or languages supported by the .NET Framework that you intend to use to develop your apps. 大量语言可供选择,包括来自 Microsoft 的 Visual BasicC#F#, 和 C++/CLIA number of languages are available, including Visual Basic, C#, F#, and C++/CLI from Microsoft. (一种用于开发 .NET Framework 应用的编程语言,它遵循公共语言基础结构 (CLI) 规范。)(A programming language that allows you to develop apps for the .NET Framework adheres to the Common Language Infrastructure (CLI) specification.)

  3. 选择并安装将用于创建应用并支持所选程序语言的开发环境。Select and install the development environment to use to create your apps and that supports your selected programming language or languages. 适用于 .NET Framework 应用的 Microsoft 集成开发环境 (IDE) 是 Visual StudioThe Microsoft integrated development environment (IDE) for .NET Framework apps is Visual Studio. 它提供多种版本。It's available in a number of editions.

若要深入了解如何开发面向.NET Framework 的应用,请参阅开发指南For more information on developing apps that target the .NET Framework, see the Development Guide.

TitleTitle 说明Description
概述Overview 为构建面向 .NET Framework 的应用的开发人员提供详细信息。Provides detailed information for developers who build apps that target the .NET Framework.
安装指南Installation guide 提供有关安装 .NET Framework 的信息。Provides information about installing the .NET Framework.
.NET Framework 和带外版本The .NET Framework and Out-of-Band Releases 介绍 .NET Framework 带外版本以及如何在应用中使用它们。Describes the .NET Framework out of band releases and how to use them in your app.
系统要求System Requirements 列出运行 .NET Framework 的硬件和软件要求。Lists the hardware and software requirements for running the .NET Framework.
.NET Core 和开放源代码.NET Core and Open-Source 介绍 .NET Core 与 .NET Framework 的关系,以及如何访问开放源代码 .NET Core 项目。Describes .NET Core in relation to the .NET Framework and how to access the open-source .NET Core projects.
.NET Core 文档.NET Core documentation 提供 .NET Core 的概念和 API 参考文档。Provides the conceptual and API reference documentation for .NET Core.
.NET Standard.NET Standard 讨论 .NET Standard,这是 .NET 实现支持的版本管理规范,用于保证可在多个平台上使用一致的 API 集。Discusses .NET Standard, a versioned specification that individual .NET implementations support to guarantee that a consistent set of APIs are available on multiple platforms.

请参阅See also