.Net Framework Basics CLR CTS CTS MSIL

by | Sep 6, 2023 | .Net Core, Learn | 0 comments

CLR

(Common Language Runtime)

Responsible for program execution in .Net Framework

Some crucial role of CLR-

Memory Management: The CLR is responsible for managing memory allocation and deallocation in .NET applications. It includes automatic memory management through garbage collection, which tracks and releases memory that is no longer in use, thus relieving developers from manual memory management.

Just-In-Time (JIT) Compilation: The CLR employs a JIT compiler to convert Intermediate Language (IL) code into machine code specific to the target platform during runtime. This process improves performance by optimizing code execution and adapting it to the underlying hardware.

Exception Handling: The CLR provides a robust exception handling mechanism. It allows developers to catch and handle exceptions, ensuring that applications can gracefully handle unexpected errors or exceptional situations during runtime.

Security and Code Access: The CLR enforces security measures to protect against unauthorized or malicious code execution. It implements code access security, which restricts code from performing actions that are not permitted based on defined permissions and trust levels. It helps maintain application integrity and prevents unauthorized access to sensitive resources.

“Here, Security means, code scope will be at our application level only, it will not interfere OS level security. Like File operations, changing the base OS files to make system venerable and so on.”

Language Interoperability: The CLR supports multiple programming languages, enabling them to interoperate seamlessly within the .NET ecosystem. It provides a common execution environment, runtime services, and a set of standard libraries that can be accessed by various .NET languages, promoting language interoperability and code reuse.

These are some of the crucial tasks performed by the CLR to ensure efficient and secure execution of .NET applications. The CLR’s capabilities enable developers to focus on writing code while benefiting from automatic memory management, performance optimizations, exception handling, and language interoperability provided by the runtime.

CLS

(Common language specification)

Means– Does not matter which programming language you wrote the code, by time of execution, all the language will convert to common language.

(MSIL) : (Microsoft Intermediate Language)

Also known as Common Intermediate Language. is a low-level, platform-independent bytecode language used by the .NET Framework.

MSIL is a platform-independent representation of the code.

Language designers have to use common subset of basic language feature that all language have to follow.

All will turn into MSIL code in the end.

Example-

VB code-

C# Code-

Converted Common code(MSIL)

CTS

 All about data types!

It defines how types are declared, used and managed.

Enable cross language integration, type safety, ensure high performance code execution.

Also provide object-oriented model.

Provides a Library that contains the primitive data types (basic or fundamental data types like string, float, double, int etc.)

Example-

VB

Dim a As integer

C#

Int a;

Compilation

 

code Compilation .Net Core

JIT:
Just in time compiler will not compile pile of code at once, like in application we have 50 webforms, but at a time, we are opening one form. So just in time compiler will compile the required code into Machine code on demand. Then enhance performance.

JIT target code is depended on Machines operating system like android, windows.

 

Hopefully I am able to explain this concept in easier way. In future I will improve this content, please comment below how I can make this easy to understand.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Related Posts

Delegates in C#: Complete tutorial

Learn Delegates c# In C#, a delegate is a type that represents references to methods with a particular parameter list and return type. Delegates provide a way to encapsulate a method, and they are often used for defining callback methods and implementing event...

Inheritance in C# oops complete guide

Inheritance Table of content: Topics1Why i wrote this article2Inheritance - complete guide3All possible scenarios based/ tricky in/out type of Interview questions Why i wrote this article? When I was preparing c#/oops, the main challenge was information was scattered...

Learn Angular Directives

Angular Directives Angular directives are an essential part of the Angular framework, allowing you to extend the HTML vocabulary to build dynamic and interactive web applications. There are three main types of directives in Angular: Components: Components are the most...

.Net Core Garbage Collector

Garbage collection   Garbage collection (GC) in .NET Core is an automatic memory management technique that reclaims unused memory. It simplifies memory management for developers and reduces memory leaks and bugs.   The GC identifies and collects objects that...

Most Useful Git Commands

Git commands you should know: git init: Initializes a new Git repository in the current directory. git clone [repository_url]: Creates a copy of a remote repository on your local machine. git add [file]: Stages changes for commit. You can use git add . to stage all...

.Net Core Introduction

INTRODUCTION .NET Core is a modern, cross-platform, and open-source development platform developed and maintained by Microsoft. It provides developers with a fast, flexible, and modular framework for building applications for Windows, Linux, macOS, iOS, and Android....

Delegates in C#: Complete tutorial

Learn Delegates c# In C#, a delegate is a type that represents references to methods with a particular parameter list and return type. Delegates provide a way to encapsulate a method, and they are often used for defining callback methods and implementing event...

Inheritance in C# oops complete guide

Inheritance Table of content: Topics1Why i wrote this article2Inheritance - complete guide3All possible scenarios based/ tricky in/out type of Interview questions Why i wrote this article? When I was preparing c#/oops, the main challenge was information was scattered...

Learn C# oops Polymorphism

Polymorphism Simplifying Polymorphism in C# with Examples Polymorphism is a fundamental concept in object-oriented programming (OOP), and it can be understood more easily by breaking it down into its key components. What is Polymorphism? At its core, polymorphism...

Learn Angular Directives

Angular Directives Angular directives are an essential part of the Angular framework, allowing you to extend the HTML vocabulary to build dynamic and interactive web applications. There are three main types of directives in Angular: Components: Components are the most...

.Net core Fun FACTS to choose other backend but NOT .Net Core

Funny Excuses to Avoid Learning and Using .NET Core for Your Next Backend Web API (And Why You Should Consider Node.js and Other Popular Alternatives Instead) In the world of backend web development, there are numerous technologies to choose from. One option that...

.Net Core Garbage Collector

Garbage collection   Garbage collection (GC) in .NET Core is an automatic memory management technique that reclaims unused memory. It simplifies memory management for developers and reduces memory leaks and bugs.   The GC identifies and collects objects that...

Most Useful Git Commands

Git commands you should know: git init: Initializes a new Git repository in the current directory. git clone [repository_url]: Creates a copy of a remote repository on your local machine. git add [file]: Stages changes for commit. You can use git add . to stage all...

Commonly used commands for .net Core Good to remember

Most userful commands for .net Core. Good to remember. dotnet new: This command is used to create a new project based on a specified template. It generates the basic structure and files required for a .NET Core application. Example: dotnet new console dotnet clean:...

.Net Core Introduction

INTRODUCTION .NET Core is a modern, cross-platform, and open-source development platform developed and maintained by Microsoft. It provides developers with a fast, flexible, and modular framework for building applications for Windows, Linux, macOS, iOS, and Android....

.Net Core vs .Net Framework differences

CLR vs Core CLR What is CoreCLR The CoreCLR provides many similar functionalities as the CLR, but it is specifically designed for the cross-platform nature of .NET Core. General CLR feature includes features like Just-In-Time (JIT) compilation, garbage collection,...

Understand Middleware in .Net Core

Middleware is a piece of software that handles http request and response. In simple term, .net core works with middleware in order to enhance performance of our application rather than having big chunk of framework component/ libraries at once, for which most of the...

Learn How .Net Core Hosting Works

Hosting In .NET CoreIn ASP.NET Core, there are two hosting models available: in-process hosting and out-of-process hosting.In-process Hosting (Default): In the in-process hosting model, a single web server (e.g., IIS) is used directly to host the application. To...