Basics of .NET Framework
Basics of .NET Framework
If we really want to understand the architecture of .NET framework, it is extremely important to understand the basic concepts like:
- Garbage Handling
- Intermediate Code Generation
- Language Interoperability
Let’s talk about some terms and concepts which would help you understand the above concepts.
Microsoft Intermediate Language –
Coffee lovers! Do you remember the bytecode in Java?
The concept of MSIL, Microsoft Intermediate Language is similar to it. When the .NET code is compiled, it gets converted to MSIL, which is not specific to any language and simply makes it attain portability or platform independence.
.NET supports many languages and each of these .NET languages when compiled gets converted to Common intermediate language (CIL) , which is platform independent. The next step would be to convert this intermediate, platform independent code into platform-specific machine-readable code which is done via CLR, Common language runtime.
Just-in-Time Compiler –
The just-in-time (JIT) compiler compiled MSIL into native code particular to the operating system (OS) and the machine architecture being used. It examines the metadata for any illegal access and suitably handles violations. JIT turns MSIL into a code directly executable by the CPU. The conversion is performed steadily during the execution of program.
JIT compilation also has some other advantages like environment specific optimization which is basically that every software application should use minimum memory and should take minimum time to execute. Also, JIT compilation takes care of run time safety by preventing spurious type conversion, as illegal conversions can lead to undesirable situations.
When a program is compiled, the MSIL code is stored in an Assembly. Assemblies contain both executable files and libraries. There are basically two types of assemblies:
- EXE – Process Assemblies
- DLL – Library Assemblies
Garbage Collection –
One of the earliest programming language to have the most important feature of Garbage collection was C#. A lot of languages supported by .NET Framework has this feature of garbade collection.
As it typically defines itself, It collects garbage, frees or removes the objects that are no longer in use i.e. those who have no references in this program. It basically helps developer not to invest time in explicitly freeing every memory element that got created. This problem of garbage collection was quite visible in case of C programs that used pointers and we often heard about dangling pointer concepts.
The values provided by C# CLR are allocated on runtime stack and they are reclaimed automatically when the code exits.
You can also read about my first post in this series - Concept of Software Framework here.
So, that's all in this post about basics of .NET Framework. Until next time, that’s all from my side. Feel free to reach out to me @Nowayhecodes!