Different components of the .NET framework

15 september 2021 om 10:00 by ParTech Media - Post a comment

To the uninitiated, the .Net framework is a platform to create and run web, console, Windows, and services-based applications using C#, F#, VB .Net, and many more programming languages. It is based on Object-Oriented Programming and runs on the Windows platform. In other words the applications that are created based on the .Net framework are hosted in Windows systems.

.NET framework comes with multiple components that have made it the powerful framework it is today. In this post, we will understand its different components and how they are useful to us.

Table of contents

  1. Components of .Net framework
  2. Conclusion

Components of .Net framework

Here are the major components of the .Net framework.

  1. Common Language Runtime (CLR)
  2. Base Class Library (BCL)
  3. Framework Class Library (FCL)
  4. Common Type System (CTS)
  5. Common Language Specification (CLS)

Let us understand them in detail.

Common Language Runtime (CLR)

Common Language Runtime (CLR) is an interoperable runtime environment from the .Net framework which provides an environment to run all .Net programs. It helps in converting the source code to native code; It is a two-step process where the source code is first converted to a Microsoft Intermediate Language (MSIL) and then CLR uses JIT compilers to convert MSIL code to native code. There are over 15 language compilers that convert the source code to MSIL code.

CLR takes care of exception handling, memory, and thread management. CLR contains a Garbage Collector (GC) which takes care of memory management by cleaning up out-of-scope objects from the memory.

Base Class Library

The base class library encapsulates a large number of common functions which can be used by the developers. They are the foundational types and act as the base for all the .NET class libraries. App-specific libraries will be built on top of BCL.

They are developed with general implementations with a high-performance policy such as low-latency, high throughput, low-memory, and low-CPU usage. Features such as ADO.Net, XML handling, Threading, Security, Diagnosis, etc., are part of the base class library.

BCL is divided into 2 parts. One is a User-defined class library (which consists of a collection of parts of an application such as dll or exe file) and another is a predefined class library that consists of namespaces.

Framework Class Library (FCL)

Framework Class Library is a collection of classes, interfaces, namespace, data, and value types that are used for .Net applications. It is a superset of the base class library. It consists of in-built classes that support base and user-defined data types, input/output and streaming operations, web-client, server, and Windows based GUI applications creation and underlying communication systems.

The functionality of FCL can be broadly classified into three categories.

  1. Utility Features,
  2. Wrapper Around OS functionality, and
  3. Frameworks

Utility features include different collection classes. For example list, stack, queue, dictionary, etc. It also includes regular expression (regex) classes.

Wrapper around OS functionality includes classes that act as a wrapper to communicate with OS components such as file system, network features, and console application operations.

Frameworks include the technology used to develop ASP.NET web application, Windows Presentation Foundation (WPF), etc.,

Common Type System

The common type system is responsible for declaring, using, and managing types in the CLR. They play a vital role in cross-language integration. CTS ensures type safety, high-performance code execution, and defining rules that language must follow. Also, it offers primitive data types (boolean, byte, int32, char, uInt64).

All types in .Net are either value and reference types. Value types are data types with the objects directly representing the object’s actual value. On the other hand, reference types are objects that are represented by a reference to the object’s actual value. When a reference type is assigned to a variable, the original value of the object is getting assigned and no copy is made, unlike value types.

Value types are stored in the stack while reference types are stored in the managed heap.

There are 5 categories of type in .Net

  1. Classes,
  2. Structures,
  3. Enumerations,
  4. Interfaces, and
  5. Delegates.

Out of these, Classes and delegates are reference types. Structures and Enumerations are value types. An interface can be either value or reference type based on the class or structure that implements it.

Common Language Specification

Common Language Specification (CLS) is a subset of CLR. CLS comes in handy when codes of different programming languages based on the .Net framework are referred to in the same solution. There are many programming languages that have .Net as the background. Example, C#, F#, VB .Net, etc., And every programming language has its own syntax.

Consider a situation - In C#, we create two methods, one with Pascal casing and another one with camel casing. This code will be accepted. And in the same solution, if a VB. Net project is added and when it refers to the C# project, then it would throw errors.

To avoid these, at the compilation time, when the source code is converted to MSIL, the code has to comply with the common language specifications. If they do not, then a non-compliant compiler warning will be displayed which serves as a heads up to the developer.

Conclusion

In the previous blogs, we have seen some important aspects and features of .Net such as Garbage collection. .Net provides a plethora of in-built features and offers extensive support for building powerful applications through its wide array of components.