Note For Students:
This is for Just for Student Logic and reference it is
not a final Notes for first Chapter
Chapter No 1.
Introduction to.NET Framework
What is.NET?
What is.NET?
• .NET is a not a programming Language it is frame work to provide collections of
languages and tools to develop various applications like Mobile application,
Desktop application & Web applications.
• Single platform for various applications .
• Designed and developed by Microsoft and the first beta Version released in 2000
• The first version of the .NET Framework Was Released in the year 2002
Why Develop .NET
Why Develop .NET
Goals and Applications
• Web applications.
• Windows applications.
• Phone Applications.
Salient Features
• Less Coding & Increased Reuse of Code.
• Reliability.
• Security.
• Language Interoperability.
• Deployment.
Language Interoperability.
Suppose before 2000 we used java language for mobile application we
get big project to develop mobile application we hire two java
developers compulsory they are java developers .
Language Interoperability.
In .NET it is not Mandatory both developers are java developers for
one project we hire different developers. This is Beauty of .NET.
11 Programming Languages Which are designed
and developed by Microsoft Are.
• C#.NET
• VB.NET
• C++.NET
• J#.NET
• JSCRIPT.NET
• WINDOWS POWERSHELL
• IRON RUBY
• IRON PYTHON
• C OMEGA
• ASML(Abstract State Machine Language)
Microsoft
.NET Architecture
Language Winforms, ADO.net,ASP.NET
Language
Framework Class Libraries
Libraries (FCL)
Common Language Runtime
(VES)
CLR Virtual Environment System (Execution Engine)
Language
The types applications that can be built in the
.NET Frame work is classified broadly into the
Following Categories.
Winforms : This is used for Developing Forms as
Applications, which would run on an end user Machine.
ASP.NET : This is used for developing web-based
applications, which are made to run on any browser such as
internet Explorer, chro.me or Firefox.(Active Server page)
ADO.NET : This technology is used to develop
applications to interact with Databases such as Oracle or
Microsoft SQL Server (Active Data Object).
Library
A class Library is A Collection of Methods and
Functions that can be used for the core purpose.
Eg:-
Class Library with methods to handle all file-level
Oprations.so there isa method which can be used to
read the text from a file.Similarly,There Is a
Method to write text to a file.
Common Language Runtime (CLR)
Java Java
Compiler execute
Hhello.java Hhello.class JVM
Source Code Byte Code
Compiler
Hhello.vb
execute
.NET Hhello.cs Hhello.exe CLR
Other .NET
language
Source Code CIL
Working of (CLR)
Source code
Language Compiler Common Language Run time Using .NET
Class Libraries.
MSIL Code
Just- in -Time Compiler Native Code
Metadata
Meta Data
Architecture of CLR
CTS CLS
(Common Type Systems) (Common Language Specification)
MSIL
Microsoft Intermediate Language
GC CM
Garbage Collector Code Manager
What is Managed Code
&
Unmanaged Code?
Managed Code &
Unmanaged Code
Operating
C# Code CLR
System
Developer
Operating
C Code
System
Developer
What is Managed Code
&
Unmanaged Code?
Managed Code- Managed code is code that run under the control
Runtime Environment Such as the .NET Common Language Runtime
(CLR) Which is Provided Services Like Automatic Memory Management
Security, and Exception Handling.
Unmanaged Code- Unmanaged code is code that run Directly on
Operating System. Out side the any Runtime Environment System and
Requires manual management of Resource and Memory .
Example of Unmanaged Code
You Birthday Party
You Decide to Organize the Birthday Party Yourself without hiring a Birthday Planner .You
need To Handle Every Details on your own ,From Calling Vendors ,Negotiting,prices
Coordinating deliveries , and setting up decorations.
1. Manual Handling- You Have To Manage every task manually ,which
requires a lot of efforts and attention to detail.
2. Potentials of Issues- Since You’re handling everything your self , there is
higher risk of missing something or encountering problems.
3. Flexibility – You have complete control over every aspect of the Birthday
party ,but it comes with responsibility of ensuring everything goes smoothly.
Example of managed Code
You Event Management Birthday Party
1. Venue.
2. Caterer .
3. Guest .
4. Decoration .
Automatic Handling- The Birthday Planner automatic manages all the tasks, and logistics
,freeing you from the burden of Coordinating everything .
Security & Reliability- You trust the Birthday Planner to ensure that everything is done
correctly and on time.
Ease & Convenience- You have a smooth & stress-free experience because the planner
takes care of the Complexities.
Managed Code Execution
Environment-Run under The Control of the .NET runtime (CLR)
Examples include applications Written in Languages like
C#,VB.NET,& F#
Resource and Libraries- Utilizes the extensive libraries & Class
Provided by .NET Framework .Benefits from built-in functionality for
tasks like file I/O, Networking ,Collections & More.
Memory Management- Memory is Managed Automatically by
the CLR using garbage Collection Reduces the risk of memory
leaks and other memory management issues.
Security & Type Safety- The CLR enforces security &type
safety. Provides built-in mechanisms to prevent common
Vulnerabilities.
Unmanaged Code Execution
Direct Execution-Run directly on the operating system
without intervention of the .NET runtime
Resource and Libraries- Does not have access to .NET
classes and libraries like system , system.IO,System.Net.
Memory Management- Memory is Managed manually
by developer require explicit allocation and deal location
of memory using functions like malloc and free.
Security & Type Safety-Security and type safety must be
handled by the developer .prone to issue like buffer
overflows ,memory leaks ,and other vulnerabilities if not
carefully managed .
COMPILER
Compiler is a special program that translates a programming language's source
code into Machine code ,byte code or another programming languages.
Machine
C# code
Target
C++ Source Program Compiler Byte code
Program Another
Java
Python Programing
Lang
JIT COMPILER
Language Interoperability
Java
Situation 1- Suppose We getting one java project & we start the project by using java
language .
JIT COMPILER
Language Interoperability
Java
Situation 2- but condition is the project will be finished in short time
JIT COMPILER
Language Interoperability
Java Java
Situation 3- We need to hire 3 Java Language Developers
JIT COMPILER
Language Interoperability
Java C#
Situation 4-But in .NET it is Not Necessary to hire same language
developers .
JIT COMPILER
Language Interoperability
Java Compiler
C# Compiler 100010010
111100101
+ 000011000
111111100
C++ Compiler
Machine Code
Python Compiler
Source codes
JIT COMPILER
Language Interoperability
Java Compiler
C# Compiler 100010010
111100101
+CLR JIT Compiler
000011000
111111100
C++ Compiler
Machine Code
Python Compiler
Source codes
This complies entire MSIL code into native code in a single compilation cycle. This
is done at the time of deployment of the application.
This complies only those methods that are called at runtime and removes them
from memory after execution.
This complies only those methods that are called at runtime. These methods are
compiled only first time when they are called, and then they are stored in
memory cache. This memory cache is commonly called as JITTED. When the
same methods are called again, the complied code from cache is used for
execution.
What is CLI
CLI is a specification developed by Microsoft that describes the
executable code and runtime environment. In simple terms this allows
us to use various high-level programming languages on various
machines without rewriting the code.
FCL(.NET Framework Class Library)
The .NET FCL is the key component of .NET framework. It provides
core functionalities of .NET architecture, which include:
.Base data types
.Object type
.Implementation of data structures
.Garbage collection
.Security, data access and database connectivity
.Network communications
.Support for implementing rich client GUI for both Windows and
Web-based applications
Base Class Library
It is subset of FCL. BCL is collection of reusable types that are closely integrated with CLR.
BCL provides classes and types that are helpful in performing day to day operation e.g.
dealing with string and primitive types, database connection, IO operations.
Common Language Specification
CLS defines the base rules necessary for any language for targeting common
language infrastructure to interoperate with other CLS-complaint Languages.
The important point to note here is that if you keep your code within CLS
boundary, your code is guaranteed to be usable in any other .NET language.
Ex:- c# uses '+' for concatenate where as vb.net uses '&‘.
So CLS defines the common rules which is followed by compilers and brings to
MSIT
Common Type System(CTS)
The Common Type System is a standard which defines how the Types are declared, used and
managed in the common language runtime, It is also an important part of the runtime support for
cross-language integration. CTS defines the basic data types that IL understands. For example, CTS
defines a type Int32, an integral data type of 32 bits (4 bytes) which is mapped by C# through int and
Vb.NET through its Integer data type.
Value Type: Contains the value that need to be stored directly on the stack or allocated inline in
a structure. It can be built in or user define
Reference Type: Stores a reference to the value's Memory address and are allocated on the
heap. Reference types can be any of the pointer types, interface or self describing types.
DLR(Dynamic Language Runtime)
It Runs at the Top of CLR. DLR is run time environment that allow us to integrate dynamic
language with CLR by adding set of services such as expression tree, call site caching, and
dynamic object interoperability to the CLR. These services include
Fast execution of dynamic operation by supporting advance caching.
A dynamic type system, to be shared by all languages using the DLR services
Dynamic method dispatch
Dynamic code generation