.NET Framework - Basics
- Software framework developed by Microsoft.
- includes a large class library - Framework Class Library (FCL).
- it has application virtual machine know as Common Language Run-time (CLR).
Framework Class Library
- collection of reusable classes, namespace and interfaces.
- Base Class Library is the core
- .NET framework implementation of the Standard Libraries as defined in the Common language infrastructure.
- FCL provides user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications.
Common Language Runtime
- CLR is the platform on which applications are hosted and executed.
- It is used to manage memory, thread execution, code execution, code safety, verification, compilation, and other system services.
- The CLR also supports a set of services that the application can use to access various resources like array, collections, operating system folders etc:
- The managed environment of the run-time eliminates many common software issues. For example the run-time automatically releases the object when they are no longer being used.
- This automatic memory management resolves the memory leaks and invalid memory references.
- It implements a strict type and code verification infrastructure called Common Type System (CTS).
Design Principles:
- Interoperability :
- Language independence
- Portability
- Security
- Memory management
- Simplified deployment
- Performance
The Role of .NET Framework:
The .NET Framework has two main components: the common language runtime (CLR) and the .NET Framework class library. The common language runtime is the foundation of the .NET Framework. CLR act as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and facilitates with code accuracy that ensure security and robustness. The concept of code management is a fundamental principle of the CLR. Code that targets the CLR is known as managed code, while code that does not target the CLR is known as unmanaged code.
The class library, is a integral component of the .NET Framework, consists of object-oriented collection of reusable classes (types) that we can use to develop applications ranging from traditional command-line or any graphical user interface (GUI) applications such as Windows Forms, ASP. NET Web Forms and Windows Services the newly invented XML Web services.
The European Computer Manufacturers Association (ECMA) standard has defines the Common Language Specification (CLS); this enforces that software development languages should be inter-operable between them. The code written in a CLS should be compliant with the code written in another CLS-compliant language. Because the code supported by CLS-compliant language should be compiled into an intermediate language (IL) code. The CLR engine executes the IL code. This ensures interoperability between CLS-compliant languages. Microsoft .NET Framework supports Languages like Microsoft Visual Basic .NET, Microsoft Visual C#, Microsoft Visual C++ .NET, and Microsoft Visual J# .NET.
The language compilers generate an Intermediate Language code, called Microsoft Intermediate Language (MSIL), which makes programs written in the .NET languages inter-operable across languages.
The ECMA standard, Common Language Infrastructure (CLI), defines the specifications for the infrastructure that the IL code needs for execution. The CLI provides a common type system (CTS) and services such as type safety, managed code execution and side by side execution.
Execution Process
Choosing a compiler :
- You can choose one or more language compiler targeting the run time such as VB. C#, Visual C++.
Compiling your code to MSIL
- When you compile source code into MSIL, it generated metadata. MSIL is a CPU independent set of instruction that can be efficiently changed to native code.
- The instruction for loading, storing, initializing, arithmetic and logical operations, control flow, direct memory access, exception handling, calling methods on objects and so many other operations are included in MSIL.
- At the time of creating MSIL the compiler also generates the metadata that describes the types, Reference and value type, in your code along with each type definition, the signature of each type's members, members referenced by your code, and other data that the runtime uses at execution time.
- Metadata are basically information about the compiled time.
- The MSIL and metadata are contained in a portable executable file, which is standard format for processor - specific execution.
- While executing your application JIT translate the MSIL into native code. When this compilation is performed, the code must be passed through a verification process that examines to check whether the code is type safe or not. It means that it is known to access the authorized memory location.
- JIT compilation allows the fact that some code might never get called during execution. Instead of using time and memory to convert all IL to native code, it converts the IL as needed during the exection and stores the resulting native code so that it is accessible for subsequent call.
- The runtime also supports another way of compilation known as install-time code generation. It converts all the MSIL into native code in single shot by taking larger unit of code at a time. The entire assembly is converted into native code at the installation time only.
Executing the code:
- The method must be complied to processor specific code before running.
-Each method for which MSIL is there is JIT complied, when it called for first time and then run.
- Next time when the method is run, the existing JIT complied native code is run.
No comments:
Post a Comment