The .NET Framework is simply a collection of two components
- FCL (.NET Framework Class Library)
- CLR (Common Language Runtime)
1. .NET Framework Class Library (FCL)
- The .NET Framework class library contains the necessary library classes that are needed for development of different types of .NET applications like Console applications, Windows applications, Windows services, ASP.NET Web sites, ASP.NET Web Services, Windows Communication Foundation (WCF) applications and Windows Presentation Foundation (WPF) applications.
- The library‘s classes are organized using a hierarchy of namespaces.
- A namespace is nothing but a collection of classes.
- For example, all the classes for performing I/O operations are located in the System.IO namespace.
- All the types (structures and classes) are commonly available for all the .NET languages. This concept can be called as ―CTS (Common Type System).
( i ). Naming Convention :
We have to follow these naming conventions for good practice of programming:
For Namespace, Classes, Structures and Methods:
- Each world in the name space should be started with upper case character.
- Ex: WebControls, Threading, OleDbClient, InitializeComponent() etc.
For Variables and objects:
- This is programmer‘s choice. You can maintain all the characters in lower case (or) you can also maintain the naming convention recommended for namespaces.
- Ex: i, abc, Abc, AbcXyz etc
( ii ). The .NET Framework Class Library (FCL) Architecture :
The .NET Framework Class Library contains the following namespaces.
Note: A namespace is a collection of few classes or namespaces.The inner namespaces, contained by another namespace is called as sub namespace. The most frequently used namespaces of FCL are listed here.
2. Common Language Run Time (CLR)
- The Common Language Runtime (CLR) is the agent that manages your .NET applications at execution time. In other words, CLR is the completely responsible component of .NET Framework that is responsible to manage the .NET applications at run time.
- In other words, The Common Language Runtime (CLR) is the virtual machine in the .NET Framework.
- It provides core services such as memory management, thread management, exception handling, security and resource management.
- A .NET application is compiled into a ―bytecode‖ format known as MSIL (Microsoft Intermediate Language). The MSIL bytecode allows .NET applications to be portable (at least theoretically) to other platforms because the application is compiled to native code only during runtime.
- During execution, the CLR‘s JIT (just - in - time) compiles the bytecode into the processor‘s native code and executes the application.
( i ). Assemblies and Microsoft Intermediate Language (MSIL) :
- In .NET, when an application is compiled, into a bytecode called MSIL. That MSIL code is stored in an assembly. The assembly is contained in one or more PE (portable executable) files and may end with an EXE or DLL extension.
- The assembly contents are:
-> Byte code — The code in MSIL language.
-> Security Information — Information about the users / user types, who can
access the assembly.
-> Manifest — Information about the assembly, such as identification, name,
version, and so on.
-> Versioning — The version number of an assembly.
-> Metadata — Information that describes the types and methods of the assembly.
( ii). Types of Assemblies
- Private Assemblies: The private assemblies are simple types. An assembly that can be used only within a software application is called as Private assembly. This type of assemblies contains ―.exe file extension.
- Shared Assemblies: An assembly that can be used by one or more software applications is called as Shared Assemblies. This type of assemblies contains .dll(dynamic linking library) file extension.
Example:
To get a better idea of a MSIL file and its content, take a look at the following example, which has two console applications. One is written in C# and the other is written i n VB.NET.
The following C# code displays the “Hello, World” message in the console window :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloWorldCS
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(―Hello, World!‖);
Console.ReadLine();
}
}
}
The Main method of the C# MSIL looks like this:
.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 19 (0x13)
.maxstack 8
IL_0000: nop
IL_0001: ldstr ―Hello, World!‖
IL_0006: call void [mscorlib]System.Console::WriteLine(string)
IL_000b: nop
IL_000c: call string [mscorlib]System.Console::ReadLine()
IL_0011: pop
IL_0012: ret
} // end of method Program::Main
The important thing to note here is that regardless of the language you use to develop your .NET applications, all .NET applications are compiled to the MSIL bytecode as this example shows.
Note: MSIL can also be called as IL (Intermediate Language) and CIL (Common Intermediate
Language).
The RTE (Run Time Environment) of a .NET Application
Common Language Runtime Video
CLR Video 2 Click Here
Role of CLR Video Click Here
No comments:
Post a Comment