.net CLR 和 CLI - 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/480752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CLR and CLI - What is the difference?
提问by Naveen
I want to know what exactly is the difference between CLR & CLI? From whatever I have read so far, it seems to indicate that CLI is a subset of CLR. But isn't everything in the CLR mandatory? What exactly may be left out of CLR to create a CLI?
我想知道 CLR 和 CLI 之间到底有什么区别?从我目前所读到的内容来看,似乎表明 CLI 是 CLR 的一个子集。但是 CLR 中的所有内容都不是强制性的吗?在创建 CLI 时,CLR 可能会遗漏什么?
回答by Cody Brocious
The CLRis Microsoft's implementation of the CLI standard.
回答by Rahul Bhatnagar
CLR is the execution environment in which a .NET application is safely hosted/run.
CLR 是安全托管/运行 .NET 应用程序的执行环境。
You can see it as .NET's private Operating System that initiates and loads just before a .NET application starts.
您可以将其视为 .NET 的私有操作系统,它在 .NET 应用程序启动之前启动和加载。
The CLR takes care of certain essential requirements of any .NET application that otherwise would require lot of deliberate code to be written in order to implement; requirements that are holistic in nature and essential to any kind of application to run in a good, efficient and safe manner [e.g. Handle memory allocation and release it when not required, avoid dangling pointers, avoid type-casting errors etc. ]
CLR 负责处理任何 .NET 应用程序的某些基本要求,否则需要编写大量深思熟虑的代码才能实现;本质上是整体的并且对于任何类型的应用程序以良好、高效和安全的方式运行必不可少的要求[例如处理内存分配并在不需要时释放它,避免悬空指针,避免类型转换错误等]
CLI on the other hand is a specification/set of guidelines that explains how to implement an application execution environment and the nature of generated application code that allows for multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.
另一方面,CLI 是一个规范/指南集,它解释了如何实现应用程序执行环境和生成的应用程序代码的性质,允许在不同的计算机平台上使用多种高级语言,而无需针对特定架构进行重写。
CLI is developed by Microsoft and standardized by ISO and ECMA.
CLI 由 Microsoft 开发并由 ISO 和 ECMA 标准化。
The CLR is a practical implementation of CLI's VES [Virtual Execution System] section and forms one of the core components of the MS.NET platform
CLR 是 CLI 的 VES [Virtual Execution System] 部分的实际实现,是 MS.NET 平台的核心组件之一
In a layman's language, CLI is a recipe while CLR is the cuisine :-)
通俗地说,CLI 是一个食谱,而 CLR 是美食 :-)
回答by xtrem
The CLR (Common Language Runtime) is Microsoft's implementation of the VES (Virtual Execution System). The VES along with the CTS (Common Type System), the CLS (common language specification) and the metadata specification are all part of the CLI (Common Language Infrastructure) specification.
CLR(公共语言运行时)是微软对 VES(虚拟执行系统)的实现。VES 连同 CTS(通用类型系统)、CLS(通用语言规范)和元数据规范都是 CLI(通用语言基础设施)规范的一部分。
The VES is a standardized virtual machine specification that must be implemented in order to load and execute CIL (Common Intermediate Language) modules (dll and exe). A VES implementation also provide runtime services such as garbage collection and security.
VES 是一个标准化的虚拟机规范,必须实现它才能加载和执行 CIL(通用中间语言)模块(dll 和 exe)。VES 实现还提供运行时服务,例如垃圾收集和安全性。
回答by Alev Ryustemov
CLR is the .net execution environment where all kind of .net applications are run.For instance, when you write your code with C# or another language from the dot NET stack the compiler compiles and converts it into managed module. A managed module is IL (intermediate language) and metadata.Above all, the important point to remember is that whenever you compile your source code, the compiler translates it into managed module. To clarify, this is not a machine code that your processor will execute.In fact, IL is an intermediate language close to assembly language.Similarly, it is also famous as object orientated machine language.
CLR 是运行所有类型 .net 应用程序的 .net 执行环境。例如,当您使用 C# 或 dot NET 堆栈中的其他语言编写代码时,编译器会编译并将其转换为托管模块。托管模块是 IL(中间语言)和元数据。最重要的是,要记住的重要一点是,无论何时编译源代码,编译器都会将其转换为托管模块。澄清一下,这不是您的处理器将执行的机器代码。实际上,IL 是一种接近汇编语言的中间语言。同样,它也以面向对象的机器语言而闻名。
Check this article about more detailed explanation:
查看这篇文章了解更详细的解释:
http://alevryustemov.com/programming/common-language-runtime/
http://alevryustemov.com/programming/common-language-runtime/
回答by zar
As answered, CLR is microsoft implementation. The component itself is called C++/CLI in Visual Studio installer but once it's installed, it shows up as CLR.
正如所回答的,CLR 是微软的实现。该组件本身在 Visual Studio 安装程序中称为 C++/CLI,但一旦安装,它就会显示为 CLR。
You can got to add remove programs >> Visual Studio 2009, modify installation and add or remove C++/CLI. It is listed like that as shown in screenshot below but again once installed, the project type is called CLR in visual studio.
您可以添加删除程序>> Visual Studio 2009,修改安装并添加或删除C++/CLI。它的列表如下面的屏幕截图所示,但再次安装后,项目类型在 Visual Studio 中称为 CLR。
回答by maddy
CLR is the complete environment in which CLI ,CTS,CLS works in integration it also incluse garbage collection,memory management ,security,intemediate language for native code... CLIis a specification for the format of executable code, and the runtime environment that can execute that code.
CLR 是 CLI、CTS、CLS 集成工作的完整环境,它还包括垃圾收集、内存管理、安全性、本机代码的中间语言...... CLI是可执行代码格式的规范,以及运行时环境可以执行该代码。


