Session 1: In-Depth Explanation
Lecture Topics:
- Introduction to the .NET Framework
- Intermediate Language (IL)
- Assemblies and their structure, EXEs/DLLs
- CLR and its functions
- JIT Compilation
- Memory Management
- Garbage Collection
- AppDomain Management
- CLS, CTS
- Security
No Lab
Lecture: Detailed Explanation
1. Introduction to the .NET Framework
The .NET Framework is a development platform by Microsoft that provides a managed environment for building, deploying, and running applications across various devices and platforms. For PG-DAC February 2025, the focus is on .NET 6, a cross-platform, open-source version of .NET that unifies the .NET ecosystem (replacing .NET Framework, .NET Core, and others).
- Key Features of .NET 6:
- Cross-Platform: Runs on Windows, macOS, Linux, Android, and iOS.
- Unified Framework: Combines .NET Framework, .NET Core, Xamarin, and Mono into a single platform.
- High Performance: Optimized for speed with features like minimal APIs and improved JIT compilation.
- Support for Modern Development: Includes ASP.NET Core for web apps, Blazor for web UI, and Entity Framework Core for data access.
- Open Source: Available on GitHub, with community contributions.
- Long-Term Support (LTS): .NET 6 is an LTS release, supported for three years (until November 2024).
- Components of .NET 6:
- Common Language Runtime (CLR): Executes managed code, providing services like memory management and security.
- Base Class Library (BCL): A rich set of reusable classes (e.g.,
System.String
, System.Collections.Generic
).
- Tools: Includes Visual Studio 2022, MSBuild, and the .NET CLI (
dotnet
command).
- Languages: Primarily C# (used in this course), but also supports F# and others.
- Why This Matters:
- Understanding .NET 6 provides the foundation for building modern, cross-platform applications.
- It’s the backbone for technologies covered in later sessions (e.g., ASP.NET Core, Entity Framework).
2. Intermediate Language (IL)
Intermediate Language (IL), also known as Common Intermediate Language (CIL), is a low-level, platform-agnostic instruction set generated by .NET compilers.
- Definition:
- When you compile C# code, the compiler (e.g., Roslyn for C#) translates it into IL, stored in assemblies.
- IL is executed by the CLR’s Just-In-Time (JIT) compiler, which converts it to native machine code at runtime.
- Example:
-
C# code:
public class Program
{
public static void Main()
{
Console.WriteLine("Hello, .NET!");
}
}
-
Corresponding IL (viewed with ILDASM):
.method public hidebysig static void Main() cil managed
{
.entrypoint
ldstr "Hello, .NET!"
call void [System.Console]System.Console::WriteLine(string)
ret
}
-
Explanation:
ldstr
: Loads the string "Hello, .NET!".
call
: Invokes Console.WriteLine
.
ret
: Returns from the method.
- Key Points:
- IL is platform-independent, enabling .NET’s cross-platform capability.
- ILDASM (IL Disassembler, covered in Session 2) allows inspecting IL code.
- IL enables optimizations by the JIT compiler and supports multiple languages (e.g., C#, F#).