What is .net framework? Explain CLR, CTS and CLS

What is .net framework? Explain CLR, CTS and CLS

.NET FRAMEWORK

The .net framework is one of the tools provided by the .NET infrastructure and tools component of the .NET platform.the .NET platform provides a new environment for creating and running robust, scalable and distributed applications over the web.
 
The .NET Framework provides an environment for building, deploying and running web services and other applications. It consists of three distinct technologies these are:
 
1.Common Language Runtime (CLR)
2. Framework Base Classes
3. User and program interfaces (ASP .NET and Winforms)
 
The CLR is the core of the .NET Framework and is responsible for loading and running C# programs. Base classes provide basic data types, collection classes and other general classes for use by C# and other .NET languages. The top layer contains a set of classes for developing web services and to deal with the user interface.
 
COMMON LANGUAGE RUNTIME
 
The Common Language Runtime, popularly known as CLR is the heart and soul of the .NET Framework. As the name suggests, CLR is a runtime environment in which programs written in C# and other .NET languages are executed. It also supports cross-languages interoperability.
The CLR provides a number of service that include:
1. Loading and execution for applications
2. Memory isolation for applications
3. Verification of type safety
4. Compilation of IL into native executable code
5. Providing metadata
6. Memory management (automatic garbage collection)
7. Enforcement of security
8. Interoperability with other systems
9. Managing exceptions and errors
10. Support for tasks such as debugging and profiling
 

when an application is executed. The source code is compiled to IL while the metadata engine creates metadata information. IL and metadata are linked with other native code if required and the resultant IL code is saved. During execution, the IL code and any requirement from the base class library are brought together by the class loader. The combined code is tested for type-safety and then compiled by

the JIT compiler to produce native machine code, which is sent to the runtime manager for execution.

 
Common Type System (CTS)
 
The .NET Framework provides multiple language support using the feature known as Common Type System that is built into the CLR.The CTS supports a variety of types and operations found in most programming languages and therefore calling one language from another does not require type conversions. Although C# is specially designed for the .NET platform, we can build .NET programs in a
number of other languages including C++ and Visual Basic.
 
Common Language Specification (CLS)
 
The Common Language Specification defines a set of rules that enables interoperability on the .NET platform. These rules serve as a guide to third-party compiler designers and library builders. The CLS is a subset of CTS and therefore the languages supporting the CLS can use each others’ class libraries as if they are their own. Application Program Interfaces (APIs) that are designed following
the rules of CLS can easily be used by all the .NET languages.
 
Microsoft Intermediate Language (MSIL)
 
MSIL, or simply IL, is an instruction set into which all the .NET programs are compiled. It is akin to assembly language and contains instructions for loading, storing, initializing and calling methods. When we compile a C# program or any program written in a CLS compliant language, the source code is compiled into MSIL.
 
Managed Code
 
As we know, the CLR is responsible for managing the execution of code compiled for the .NET platform. The code that satisfies the CLR at runtime in order to execute is referred to as managed code. Compilers that are compatible to the .NET platform generate managed code. For example, the C# compiler generates managed code. The managed code generated by C# (and other compilers
capable of generating managed code) is IL code. The IL code is then converted to native machine code by the JIT compilers.
 
FRAMEWORK BASE CLASSES
 
.NET supplies a library of base classes that we can use to implement applications quickly. We can use them by simply instantiating them and invoking their methods or by inheriting them through derived classes, thus extending their functionality.
 
Much of the functionality in the base framework classes resides in the vast namespace called System. We can use the base classes in the system namespace for many different tasks including

1. Input/Output Operations
 
2. String handling
 
3. Managing arrays, lists, maps, etc
 
4. Accessing files and file systems
 
5. Accessing the registry
 
6. Security
 
7. Windowing
 
8. Windows messages
 
9. database management
 
10. Evaluation of mathematical functions
 
11. drawing
 
12. managing errors and exceptions
 
13. Connecting to the internet and many more
 
USER AND PROGRAM INTERFACES
 
The .NET Framework provides the following tools for managing user- and application interfaces:
 
1.Windows forms
 
2. Web forms
 
3. Console Applications
 
4. Web services
 
These tools enable users to develop user-friendly desktop-based as well as web-based applications using a wide variety of languages on the .NET platform.