Your Ad Here

Friday, March 20, 2009

Common Language Infrastructure

The Common Language Infrastructure (CLI) is the core of the .NET Framework. It is an open specification developed by Microsoft which allows .NET code to run on different platform without the code being rewritten. The advantage of CLI is that it supports multiple high-level languages. For a complete list of .NET aware languages go to http://www.dotnetpowered.com/languages.aspx. The CLI specification applies to Microsoft .NET Framework, Portable .NET, Mono, etc. The CLI consists of:-
  1. Common Language Runtime (CLR) - The CLR is the implementation of CLI which runs the Common Intermediate Language (CIL) and converts it into the native executable code supported by the platform at runtime with the help of Just-in-time (JIT) compiler. The core of the CLR is the library named mscoree.dll (Common Object Runtime Execution Engine). When an assembly (*.dll or *.exe) is called, mscoree.dll is automatically loaded, which in turn loads the required assembly into memory. The CIL or managed code is compiled only when needed, i.e., the JIT compiler converts the CIL to native code on demand at runtime. The CLR defines the Common Type System (CTS), which is a standard type system used by all .NET languages. During the execution, the CLR also provides the following services:
    1. Memory Management
    2. Thread Management
    3. Garbage Collection
    4. Exception Handling
    5. Security
  2. Common Language Specification (CLS) - It is a basic set of rules to which any language implementing the CLI must conform, so that it can seamlessly interoperate with other CLS-compliant languages. The advantage of CLS is that, the code written in any CLS-compliant language, when compiled will give the same CIL code. To check for CLS-compliance you can use a .NET attribute:
    <Assembly: System.CLSCompliant(True)>
    This will instruct the Visual Basic compiler to check your code for CLS-compliance and will give a compile time error if any CLS rule is violated.
  3. Common Type System (CTS) - It defines a number of types which can be used by all .NET languages, i.e., programs written in all CLS-compliant languages can use these types. It is categorized into value types and reference types. The CTS types are:
    1. Class
    2. Structure
    3. Interface
    4. Enumeration
    5. Delegate
  4. Common Intermediate Language (CIL) - Any .NET compliler converts the source code into managed code or CIL. CIL is the lowest-level human readable programming language. At runtime CIL is converted into native code by CLR's Just-in-time compiler. In producing the CIL code, the compiler also creates metadata and manifests which are embedded within the executable file.
  5. Base Class Libraries (BCL) - Base Class Libraries are available to all .NET programming languages. These libraries contain various namespaces which provide a number of functions such as Database Access, Threading, File I/O, Security, etc.
  6. Metadata - The information about classes and objects and their members are stored as metadata. In addition to this information about the assembly such as version information, external references, etc. are also stored in the metadata and is known as the assembly manifest.


Bookmark and Share Common Language InfrastructureSocialTwist Tell-a-Friend

0 comments:

Post a Comment

Please comment if you like my posts and suggest improvements if you disliked. You can also post your queries if you have any, and I will try to answer it.

Search