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?
问题:
回答1:
The CLR is Microsoft's implementation of the CLI standard.
回答2:
CLR is the execution environment in which a .NET application is safely hosted/run.
You can see it as .NET's private Operating System that initiates and loads just before a .NET application starts.
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. ]
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 is developed by Microsoft and standardized by ISO and 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
In a layman's language, CLI is a recipe while CLR is the cuisine :-)
回答3:
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.
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.
ECMA C# and Common Language Infrastructure Standards
回答4:
CLI, Common Language Infrastructure is the specification or criteria developed by Microsoft.
Any programming language that conforms to CLI criteria can access a common class library and can be compiled into a common intermediate language (bytecode). Once compiled into the common intermediate language, any program can then be further compiled into the machine code understood by the specific system it is running on. It describes the executable code and runtime environment. In simple terms this allows us to use various high-level languages on various machines without rewriting the code.
CLR, Common Language Runtime which is the implementation of CLI by Microsoft.
CLR is the virtual machine component in the .NET Framework better known as the runtime and is responsible for executing .NET programs. It is kind of operating system for the .NET programs that perform many functions that the program required to be handled.
where CIL is the Common Intermediate Language that fed into CLR to the further generation of machine code.
Features of the CLR:
- Memory management
- Exception handling
- Code access security
- Thread management
- Debugging
- Verification & Compilation
- Type safety
- Garbage Collection
回答5:
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... CLI is a specification for the format of executable code, and the runtime environment that can execute that code.