Sunteți pe pagina 1din 4

Common Language Runtime (CLR)

Common Language Runtime is an execution engine and a full-featured class library built to the specification of the Common Type System (CTS). CLR is responsible for loading and running the application safely. It handles garbage collection and security checks. Code that runs in CLR is called managed code. The CLR class library provides hundreds of useful types that can be used as they are or be extended through inheritance.Developers will need to know the CLR. The CLR is what you will be programming directly against. Language- and tool vendors who wish to target the .NET platform need to understand the details of CTS and Common Language Speci.cation (CLS the runtime as an agent that manages the code at execution time providing services like memory management, thread management, code execution, code safety verification and compilation. The runtime enforces strict type and code-verification. The CTS ensures that all code is self-describing.Having the .NET compiler insert metadata that carry information about the resources needed like types, references and member variables. The runtime uses metadata to .nd and load classes and to be able to (layout) done space for instances. The CLR handles automatic memory management, like garbagecollection, this eliminates common errors like invalid memory references and memory leaks. To handle interoperability between programming languages, the .NET Framework types are CLS compliant and can therefore be used from any programming language that targets the CLR and supports the CLS. Code written in different .NET languages can be combined. CLR is an implementation of the Common Language Infrastructure (CLI) speci.cation, adding COM+ interoperability and Windows platform access services.In particular CLR over dynamic loading and unloading, garbage collection, context interception, metadata rejection, remoting, persistence and other runtime services that are fully language independent. CLI defines a language neutral platform and an intermediate Language (IL) and deployment .le format (assemblies). CLI also includes support for extensible metadata. The CLR is the implementation of the CLI speci.cation. CLI comprises the speci.cation of execution engine services (such as loader, Just- In-Time (JIT) compiler and garbage-collection memory manager), the common type system CTS and the common language speci.cation Application domains Usually an operating system process is used to separate applications because memory addresses are not shared between them. In .NET the primary application boundary is the AppDomain and not a process. CLR partitions a process into one or more application domains (AppDomain). An AppDomain isolates a set of objects from all objects in other AppDomains, but is more lightweight and thus cheaper than a process. Communications across AppDomain boundaries requires marshalling (Communication through proxy objects that handle the communication channel). .NET managed code must be verified by the CLR. This means that the code is type safe and that the CLR can provide equal level of isolation as the operating system process through

application domains. This increases performance. The application domains do not have to make cross-process calls or switch between processes. Additional benefits are that individual applications can be stopped or unloaded without stopping the entire process. The CLR uses threads to execute code. Context Finer execution space beyond AppDomains is provided by Contexts. An App- Domain can contain many contexts and must contain at least one called default context. A context provides an environment with a set of properties shared by all objects that exist in the context. It provides an interception boundary for the runtime to apply pre and post processing to all method calls from outside the context. The Context is a home for objects with similar runtime requirements such as synchronisation or just-in-time activation. shows how a process can be divided into application domains, which in turn will contain one or more contexts.

CLR context infrastructure attempts to provide an extensible infrastructure for contextual composition Third parties can introduce new properties to context boundaries CLR objects come in four top-level flavors: + Value types + Pass-by-value types + Pass-by-reference types + Context-bound types Standard types include marshalling over SOAP/HTTP and DCOM

Short Answer: - Security, memory management and exception handling is


provided by CLR. It also provides application virtual machine which is chiefly responsible for taking care of the CPU performance so that programmers can code without any hassles. CLR handles the important run time environment, it handls the memory management, thread safty, security management, garbage collection, CLR converts programing code(e.g- C#, Vb.Net, J#, etc..) it into native code by using Jit-In-Time Compiler.

Common Language Runtime (CLR) The .NET Framework provides a Runtime environment called the Common Language Runtime or (CLR) that handles the execution of the code and provides useful services for the implementation of the application. CLR takes care of code management upon program execution and provides various services such as memory management, thread management, security management and other system services. The managed code targets CLR benefits by using useful features such as cross-language integration, cross-language exception handling, versioning, enhanced security, deployment support, and debugging. It is a framework layer that resides above the Operating System. .Net programs dont directly communicate with the Operating System but through CLR. Common Language Specification (CLS) Earlier we used the term .NET Compliant Language and stated that all the .NET compliant languages can make use of CLR and FCL. But what makes a language .NET compliant language? The answer is Common Language Specification (CLS). Microsoft has released a small set of specification that each language should meet to qualify as a .NET Compliant Language. As IL is a very rich language, it is not necessary for a language to implement all the IL functionality, rather it meets the small subset of it, CLS, to qualify as a .NET compliant language, which is the reason why so many languages (procedural and OO) are now running under .Net umbrella. CLS basically addresses to language design issues and lays certain standards like there should be no global function declaration, no pointers, no multiple inheritance and things like that. The important point to note here is that if you keep your code within CLS boundary, your code is guaranteed to be usable in any other .Net language. Common Type System (CTS) .NET also defines a Common Type System (CTS). Like CLS, CTS is also a set of standards. CTS defines the basic data types that IL understands. Each .NET compliant language should map its data types to these standard data types. This makes it possible for the 2 languages to communicate with each other by passing/receiving parameters to/from each other. For example, CTS defines a type Int32, an integral data type of 32 bits (4 bytes) which is mapped by C# through int and VB.Net through its Integer data type.

S-ar putea să vă placă și