CLR language applications. CLR allows us to

CLR
stands for Command Language Runtime. It is one of the main components of the
.Net framework. Common Language Runtime is a layer that lies between operating
systems and the .Net language applications. CLR allows us to perform debugging
applications during runtime. It is a software environment for programs with
.Net framework supporting languages to run and execute. All .NET programs
execute under the supervision of CLR, guaranteeing many properties and
behaviors in the areas of memory management, security, and exception handling.

Features of CLR

We Will Write a Custom Essay Specifically
For You For Only $13.90/page!


order now

ü  Memory
management

ü  Exception
handling

ü  Code
access security

ü  Thread
execution

ü  Debugging

ü  Verification
& Compilation

Memory Management

Programmers
do not need to worry on managing the memory if the programs are running under
the CLR as it provides memory management and thread management. CLR allocates
the memory for scope and de-allocates the memory if the scope is completed when
the program needs memory.

Thread
execution

 Threads are managed under the Common
Language Runtime. Threading means parallel code execution. Threads are
basically light weight processes responsible for multi-tasking within a single
application.

Responsibility
of CLR

The
main function of Common Language Runtime (CLR) is to convert the Managed Code
into native code and then execute the Program. CLR handles the execution of
code and provides useful services for the implementation of the program.
Language compilers will compile the program code to Microsoft Intermediate code
(MSIL) which will intern be compiled into native code by CLR. CLR manages the
MSIL code. In addition to executing code, CLR provides services such as memory management,
thread management, security management, code verification, compilation, and
other system services to make development process easier. To enable the runtime
to provide such services to managed code, language compilers must emit metadata
that describes the types, members, and references in the code. Metadata is
stored with the code and every loadable common language runtime portable
executable file contains metadata. The runtime uses metadata to locate and load
classes, lay out instances in memory, resolve method invocations, generate
native code, enforce security, and set run-time context boundaries. Objects
written in different languages can communicate with each other, and their
behaviors can be tightly integrated with CLR.

.Net Version and CLR Version

It
is also important to match .net version and CLR version so that program works
well. The following table shows how the two version numbers correlate.

.Net
Framework Version

CLR
Version

1.0

1.0

1.1

1.1

2.0

2.0

3.0

2.0

3.5

2.0

4

4

4.5
(4.5.1, 4.5.2)

4

4.6
(4.6.1, 4.6.2)

4

4.7

4

Just-In-Time Compiler (JIT)

JIT
is a member of Common Language Runtime. It compiles Web Service or Web Forms
files implicitly into native code. The language compiler executes IL code and
those managed code are further compiled to native code. This process is called
Just In Time compilation.

Before
MSIL (MS Intermediate Language) can be executed, it must converted by .net
Framework Just in time (JIT) compiler to native code, which is CPU specific
code that run on some computer architecture as the JIT compiler. Rather than
using time and memory to convert all the MSIL in portable executable (PE) file
to native code, it converts the MSIL as it is needed during execution and
stored in resulting native code so it is accessible for subsequent calls. There
are three types of Just in Time Compiler.

      
Pre-JIT Compiler (Compiles entire code
into native code completely)

      
Econo-JIT Compiler (Compiles code part
by part freeing when required)

      
Normal JIT Compiler (Compiles only that
part of code when called and places in cache

CLR consists of Common Type
Specification (CTS) and Common Language Specification (CLS).

Common Type Specification (CTS)

CTS
is a strict type and code verification infrastructure. The CTS supports the
general concept of classes, interfaces, delegates (which support callbacks),
reference types, and value types. The CTS ensures that all managed code is
self-describing. The various Microsoft and third-party language compilers
generate managed code that conforms to the CTS.

Features of CTS

 Everything in .NET is an object of a specific
class that derives from the root class called System.Object. For examples, System.Int32, System.Decimal, 
System.Boolean, and so on are specified data types of CTS. However,
developers are not required to use these types directly. These types are the
underlying objects of the specific data types provided in each managed
language.

System.Int32
data type of CTS

C# .Net int n=0; 

VB.Net dim n as integer=0;

As
in the example, C# programming language uses the keyword ‘int’ to declare
integer while VB .net uses ‘dim’ keyword. However, they are the same type in
the CTS with the specification named System.Int32. So, however different
languages, they all must derive from the CTS specification so that languages
can be further compiled.

There
are two types of .Net data types. They are value data type and reference data
type. Value types are also termed as primitive types and they inherit from
System.ValueType and System.Object. 
Value types are short-term objects and are allocated on the stack. Some
widely used value types are as follow.

      
byte, short, int,
long for Integer

      
float, double for
Decimal

      
char for characteristics

      
bool for True/False

References
are derived from System. Object. They are essentially pointers and allocated on
the managed heap. The object created can be customized. The address of inserted
data is stored in the object and a link exists between the object and the
actual data.

For example,                             On Memory

string
st;                          st 1101              
1101 Hello

link

st=”Hello”

It
is more difficult to remove reference data type from memory because only link
is deleted in deleting process. But .net framework has garbage collections
which remove unused or unlinked objects from memory. So, the lifetime of
reference types is controlled by the Garbage Collector.

Value
types can be converted to reference types, and vice versa, through processes
called boxing and unboxing, respectively. Boxing is helpful when a developer
needs to change the memory model of an object.

How does CTS help in code compilation?

In
developing an application, different languages can be used to develop the same
applications since .Net Framework provides multiple languages accessibility.
Common Type System ensures two different languages a smooth communication so
that they can be used together in the same application. For example, it allows
two different languages of .net e.g., C#, VB.NET to get compiled into common
base type from specified data types of each language.

Common Language Specification (CLS)

CLS
stands for Common Language Specification and it is a subset of CTS. CLS is a
set of rules or guidelines for programming languages that will be written in
IDE.  It defines the standards to which
languages on .net platform must adhere to in order to be compatible with other
.NET languages. CLS represents the guidelines to the compiler of a language,
which targets the .NET Framework. CLS acts as a tool for integrating different
languages into one umbrella in a seamless manner by executing language
instructions to compile code from different languages with the specified CLS
basic rules.

.Net
Framework Class Library (FCL)

 

.Net
framework class library is the main function. It is a collection
of reusable classes , interfaces, and value types that expedite and optimize
the development process and provide access to system functionality. The .Net
Framework class library (FCL) organized in a hierarchical tree structure and it
is divided into namespaces. Framework class library (FCL) provides the
consistent base types that are used across all .NET enabled languages. The
Classes are accessed by namespaces, which reside within Assemblies. The .Net
Framework class library (FCL) classes are object oriented and easy to use in
program developments. Moreover, third-party components can integrate with the
classes in the .NET Framework.

It
can be used for developing applications such as console applications, Windows
GUI applications, ASP.NET applications, Windows and Web services,
workflow-enabled applications, service oriented applications using Windows
Communication, XML Web services, etc.

The
.NET FCL is integrated with the Common Language Runtime (CLR) of the Framework,
which manages the code execution. Its classes follow the object model as used
by the Intermediate Language (IL) and are based on single inheritance. The
classes and interfaces are grouped into namespaces so that they can be accessed
easily.

Responsibility of FCL

The .NET FCL is the key component of
.NET framework. It provides core functionalities of .NET architecture, which
include:

      
Base data types

      
Object type

      
Implementation of data structures

      
Garbage collection

      
Security, data access and database
connectivity

      
Network communications

      
Support for implementing rich client
GUI for both Windows and Web-based applications

Basic Class Library (BCL)

The
BCL is a subset of the FCL. BCL honors the ECMA specification for the common language
infrastructure. A .NET Framework library, BCL is the standard for the C#
runtime library and one of the Common Language Infrastructure (CLI) standard
libraries. BCL provides types representing the built-in CLI data types, basic
file access, collections, custom attributes, formatting, security attributes,
I/O streams, string manipulation, and more.

Beyond
the BCL, there are many more classes that Microsoft ships with the .NET
Framework. In general, these additional things cover broad functional areas,
such as database access or graphical user interfaces (Windows Forms or WPF).
This entire collection, including the BCL, is called the Framework Class
Library, or FCL. Some of the name spaces and functions are as follow.

Go Top
x

Hi!
I'm Eleanor!

Would you like to get a custom essay? How about receiving a customized one?

Check it out