Unit 1
Unit 1
NET Framework
Execution In CLR
• It is a set of rules and constraints that all language must follow which want to be
compatible with .NET framework.
• It is used to support the theme of .NET i.e. unification and interoperability (The ability
of computer systems or software to exchange and make use of information). That
means, if we want the code which we write in a language to be used by programs in
other language(cross-language integration) then it should hold on to the CLS.
• Thus the CLS describes a set of features that are common different languages.
CLS performs the following functions:
Assembly All of the managed code that runs in .NET must be contained in an assembly.
Logically, the assembly is referenced as one EXE or DLL file. Physically, it may consist of a
collection of one or more files that contain code or resources such as images or XML data. An
assembly is created when a .NET compatible compiler converts a file containing source code
into a DLL or EXE file.
Manifest. Each assembly must have one file that contains a manifest. The manifest is a set of
tables containing metadata that lists the names of all files in the assembly, references to
external assemblies, and information such as name and version that identify the assembly.
Metadata When a compiler produces Microsoft Intermediate Language (MSIL), it also produces
Metadata (Data about Data). Metadata is nothing but a description of every namespace, class,
method, Property etc. The Microsoft Intermediate Language (MSIL) and Metadata are
contained in a portable executable (PE) file. It allows loading and locating code, enforcing code
security, generating native code, and providing reflection at runtime.
Execution in CLR
When the .NET program is compiled, the output of the compiler is not an executable file but a
file that constraints a special type of code is called Microsoft intermediate language , which is a
low level set of instructions understand by CLR.
• The MSIL defines a set of portable instructions that are CPU indendendent.
• It’s the job of the CLR to translate this MSIL into native code when the program is
executed, making the program to run in any environment for which the CLR is
implemented. And that’s how the .NET framework achieves Portability (run ( in any
environment). This is MSIL is converts into Native code using JIT(Just In Time)compiler
Purpose of CLR
• Thread Support: Threads are managed under the Common Language Runtime.
Threading means parallel code execution. Threads are basically light weight processes
responsible for multi-tasking within a single application.
• COM Marshaler: It allows the communication between the application and COM
objects.
• Type Checker Type checker will verify types used in the application with CTS or CLS
standards supported by CLR, this provides type safety.
• Exception Manager: it handles all the runtime exceptions(Error) thrown by application
• Security Engine: It enforces security permissions at code level security, folder level
security, and machine level security using Dot Net Framework setting and tools
provided by Dot Net.
• Debug Engine: CLR allows us to perform debugging an application during runtime.
• MSIL: Microsoft Intermediate Language is considered to be the lowest form of human
readable language. It is CPU independent and includes instructions of how to load,
store, initialize objects. JIT converts this MSIL into native code which is independent on
the CPU
• Code Manager: CLR manages code. When we compile a .NET application you don't
generate code that can actually execute on your machine. You actually generate
Microsoft Intermediate Language (MSIL or IL). All .NET code is IL code. IL code is also
called Managed Code, because the .NET Common Language Runtime manages it.
• Garbage Collector Garbage Collector handles automatic memory management and it
will release memory of unused objects in an application, this provides automatic
memory management.
• Class Loader: as and when needed. It loads the class into the system memory.
• Namespace is the Logical group of types (Class). We can say Namespace is a container (e.g.
Class, Structures, Interfaces, and Enumerations etc).
System.Data.SqlClient
System.Data.OleDb
System.Data.Odbc
System.IO Provides file and data stream I/O. These classes provide a way to access
the underlying file systems of the host operating system.
System.Windows.Forms Classes used to build Windows desktop GUI applications. Controls
including the ListBox, TextBox, DataGrid, and buttons are found here.
System.Xml Types for processing XML.
System.Web The Internet-related classes referred to as ASP.NET. They manage
browser-server communication requirements, manipulate cookies, and
contain the controls that adorn a Web page.
System.Web.Services Web.Services includes those classes required for SOAP-based XML
messaging.
It defines how types are declared, used, and managed in the common language runtime, and is
also an important part of the runtime's support for cross-language integration.
The common type system performs the following functions:
• Establishes a framework that helps enable cross-language integration, type safety, and
high-performance code execution.
• Provides an object-oriented model that supports the complete implementation of many
programming languages.
• Defines rules that languages must follow, which helps ensure that objects written in
different languages can interact with each other.
• Provides a library that contains the primitive data types (such
as Boolean, Byte, Char, Int32, and UInt64) used in application development.
For example, C# has an int data type and VB.NET has Integer data type. Hence a variable
declared as an int in C# and Integer in VB.NET, finally after compilation, uses the same
structure Int32 from CTS.