0% found this document useful (0 votes)
32 views

Introduction To .Net Frameworknew

The document provides an introduction to .NET framework. It discusses that .NET is a development platform from Microsoft that allows building various applications across different operating systems using languages like C# and Visual Basic. The key components of .NET include the Common Language Runtime (CLR) and .NET Framework Class Library (FCL). It also discusses the different implementations of .NET like .NET Framework, .NET Core and Xamarin/Mono and provides a brief history and evolution of .NET framework.

Uploaded by

ayushsutariya30
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Introduction To .Net Frameworknew

The document provides an introduction to .NET framework. It discusses that .NET is a development platform from Microsoft that allows building various applications across different operating systems using languages like C# and Visual Basic. The key components of .NET include the Common Language Runtime (CLR) and .NET Framework Class Library (FCL). It also discusses the different implementations of .NET like .NET Framework, .NET Core and Xamarin/Mono and provides a brief history and evolution of .NET framework.

Uploaded by

ayushsutariya30
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

Introduction to .

NET
Framework
Unit 1
What is .NET ?
NET is a free and open-source software development
platform developed by Microsoft.

It provides a framework for building various applications,


including desktop, web, mobile, gaming, and IoT
applications.

The platform includes a set of libraries, runtime, and


development tools that enable developers to build
applications using different programming languages such
as C#, F#, and Visual Basic.
What is .NET ?
 .NET is designed to simplify software development by providing
a consistent programming model and a common set of APIs that
can be used across different operating systems and devices.

 This allows developers to write code once and deploy it to various


platforms, including Windows, macOS, and Linux.

 Some of the key components of the .NET platform include the


Common Language Runtime (CLR), the .NET Framework Class
Library (FCL).
Different types of .NET Framework
There are various implementations of .NET.
Each implementation allows .NET code to execute in different
places—Linux, macOS, Windows, iOS, Android, and many more.
 .NET Framework is the original implementation of .NET. It
supports running websites, services, desktop apps, and more on
Windows.
 .NET is a cross-platform implementation for running websites,
services, and console apps on Windows, Linux, and macOS. .NET is
open source on GitHub. .NET was previously called .NET Core.
 Xamarin/Mono is a .NET implementation for running apps on all
the major mobile operating systems, including iOS and Android.

Note: .NET Framework is Platform-Dependent while .NET or .NET


Core is Platform Independent. Here, we are not talking about Web
Applications. Web Applications are independent of Operating Systems.
What is not .NET?
.NET is not an Operating system.
.NET is not a database
It is not an ERP application.
.NET is not a Testing Tool.
It is not a programming language.
History
 Microsoft began developing .NET Framework in the late 1990s, originally under
the name of Next Generation Windows Services (NGWS), as part of the .NET
strategy. By early 2000, the first beta versions of .NET 1.0 were released.
 In August 2000, Microsoft, and Intel worked to standardize Common Language
Infrastructure (CLI) and C#. By December 2001
 Release History of .NET Framework and its compatibility with the
different Windows version

.NET Version CLR Version Development tool Windows Support

1.0 1.0 Visual Studio .NET XP SP1

1.1 1.1 Visual Studio .NET 2003 XP SP2, SP3

2.0 2.0 Visual Studio 2005 N/A

3.0 2.0 Expression Blend Vista

 In April 2019, Microsoft released .NET Framework 4.8, the last major version of
the framework as a proprietary offering, followed by .NET Framework 4.8.1 in
August 2022 with Visual Studio 2019.
history and evolution of the DOT NET
Framework
 Before DOT NET Framework COM was there
What is COM?
 COM stands for Component Object Model. The COM is one of the
Microsoft Frameworks. Using this Framework, we can develop Windows
Applications (Desktop or Standalone Applications for Windows OS) as
well as Web Applications. In earlier COM, VB is the programming
language that is used to implement Windows applications and ASP is
the technology used to implement web applications.

 What are the disadvantages of COM?


 Incomplete Object-Oriented Programming means it will not support all the
features of OOPs.
 Platform Dependent means COM applications can run on only Windows OS.

 To overcome the above problems, Microsoft introduces .NET Framework.


What does .NET Represent?
 NET stands for Network Enabled Technology (Internet).
In .NET, dot (.) refers to Object-Oriented.

 So, the complete .NET means through Object-Oriented we can


implement internet-based applications.
.NET Framework Objectives
 The .NET Framework is designed to fulfill the following objectives:
 Provide object-oriented programming environment
 Provide environment for developing various types of applications, such as
 Console application
 Windows-based applications
 Web-based applications
 Web Services
 Class Libraries

 Provide environment for developing application in various programming


languages- C#, Visual Basic .NET, C++, J#
 Third-party languages: COBOL, Perl, Ruby, Pascal, LISP and many more

Note: There are many programming languages (more than 40), but only a small
amount of the .NET languages are provided or supported by Microsoft - for
example, Visual Basic .NET, C#, and more.
.NET Framework Objectives
To ensure that code based on the .NET Framework can
integrate with any other code

Targets primarily Windows OS, but Mono Project (headed


by Novell) supports Linux, Unix, FreeBSD, Mac OS X,
Solaris
Features of . NET
Some of the features of .NET are:
 Cross Language Interoperability: Cross Language Interoperability
means Language Interoperability allows a code written in one
programming language to interact with code written in other
programming languages. This helps in code reusability and thereby
improving the efficiency of the code.

 Security: It allows developers to keep an eye on operations like registry-


access operations, file-access operations and much more.

 Resource Management: .NET does automatic resource management


with the help of CLR(Common Language Runtime). The garbage
collector of the CLR serves as an automatic resource manager. The
garbage collector of CLR automatically identifies and frees memory
which is not in use, thereby preventing memory leaks. This enhances the
performance, stability and helps develop a robust application.
Features of . NET
 Type Safety: While executing the program, the type checker checks
that all the objects, its references and values have a valid type. It also
ensures that only valid operations are performed on the objects.

 Side by Side execution: The .NET framework allows developers to


deploy multiple versions of the application with help of assemblies.
Assemblies are self-contained units of deployment and is the main
building block of the .NET framework. It contains compiled data,
metadata and resources which are needed to execute and run an
application. The CLR helps to run multiple applications side by side.
.NET Framework Architecture
The .NET Framework consists of:
Components of .NET Framework
There are following components of .NET Framework:
 CLR (Common Language Runtime)
 CTS (Common Type System)
 BCL (Base Class Library)
 CLS (Common Language Specification)
 FCL (Framework Class Library)
 .NET Assemblies
 XML Web Services
 Window Services
Common Language Runtime (CLR)
 .NET Framework includes the Common Language Runtime (CLR). It
serves as the execution engine of .NET Framework and offers many
services such as memory management, type safety, exception
handling, garbage collection, security and thread management.

 All programs written for .NET Framework are executed by the CLR.

 Programs written for .NET Framework are compiled into Common


Intermediate Language code (CIL), as opposed to being directly
compiled into machine code.

 During execution, an architecture-specific just-in-time compiler (JIT)


turns the CIL code into machine code.
Execution in CLR
MSIL
 MSIL stands for Microsoft Intermediate Language.

 Microsoft Intermediate Language (MSIL) is a CPU-independent


set of instructions that can be efficiently converted to the native
code.

 We can call it as Intermediate Language (IL) or Common


Intermediate Language (CIL). During the compile time , the
compiler convert the source code into Microsoft Intermediate
Language (MSIL)
MSIL
 The Microsoft Intermediate Language (MSIL) encompasses a
comprehensive set of instructions that encompass various operations.
 These operations include loading and storing data, initializing objects,
invoking methods on objects, performing arithmetic and logical
operations, controlling program flow, managing memory access,
handling exceptions, and more.
 In essence, MSIL provides a versatile instruction set that covers a wide
range of essential programming operations.
 The Common Language Runtime's JIT compiler dynamically converts
the MSIL code into native code during runtime, enabling optimal
performance and seamless execution on the target operating system.
 This combination of MSIL and JIT compilation empowers the .Net
Framework to offer both portability and efficient native code execution,
facilitating the development and deployment of robust and
versatile .NET applications.
Managed code
 The code, which is developed in .NET framework, is known as
managed code. This code is directly executed by CLR with help
of managed code execution.

 Managed runtime environment provides different types of


services like garbage collection, type checking, exception
handling, bounds checking, memory allocation, type safety etc.
to code automatically without the interference of the
programmer.

 The application written in the languages like C#, VB.NET etc. are
always aimed at runtime environment services to manage the
execution and the code written in these types of languages are
known as managed code.
Managed code
Advantages
 It improves the security of the application like when you use runtime
environment, it automatically checks the memory buffers to guard
against buffer overflow.
 It implement the garbage collection automatically.
 It also provides runtime type checking/dynamic type checking.
 It also provides reference checking which means it checks whether
the reference point to the valid object or not and also check they are
not duplicate.
Disadvantages
 The main disadvantage of managed language is that you are not
allowed to allocate memory directly, or you cannot get the low-level
access of the CPU architecture.
Unmanaged code
 The code, which is developed outside .NET, Framework is known as
unmanaged code.
 Applications that do not run under the control of the CLR are said to
be unmanaged
 Unmanaged code compiles straight to machine code and directly
executed by the Operating System.
 Unmanaged code does not get services like security and memory
management
 All code compiled by traditional C/C++ compilers are Unmanaged
Code. COM components, ActiveX interfaces, and Win32 API functions
are examples of unmanaged code.
Unmanaged code
Advantages
 It also provides direct access to the hardware.
 It allows the programmer to bypass some parameters and
restriction that are used by the managed code framework.
Disadvantages
 It does not provide security to the application.
 Due to the access to memory allocation the issues related
to memory occur like memory buffer overflow, etc.
 Error and exceptions are also handled by the programmer.
 It does not focus on garbage collection.
Common Language Specification(CLS)
 CLS stands for Common Language Specification and it is a subset of
CTS.
 It defines a set of rules and restrictions that every language must follow
which runs under the .NET framework. The languages which follow
this set of rules are said to be CLS Compliant. In simple words, CLS
enables cross-language integration.
 The CLS is a specification that defines the rules for supporting the
language integration in a certain way that the programs are written in
any language, still, it can interoperate with the one another seamlessly
while taking the full advantage of concepts such as exceptions
handling, inheritance, polymorphism, and other features accordingly.
 These CLS rules and the specification are documented in the ECMA
proposed standard document.
Common Language Specification(CLS)
 For example, one rule is that you cannot use multiple inheritances
within .NET Framework. As you know C++ supports multiple
inheritances but; when you will try to use that C++ code within C#, it is
not possible because C# doesn’t support multiple inheritances.

 One another rule is that you cannot have members with the same
name with case difference only i.e. you cannot have to add() and
Add() methods. This easily works in C# because it is case-sensitive but
when you will try to use that C# code in VB.NET, it is not possible
because VB.NET is not case-sensitive.
Common Language Infrastructure(CLI)
 Common Language Infrastructure is a standard developed by
Microsoft that allows the use of multiple different high-level languages
on different computer platforms without rewriting the code for any
specific architecture.
 In simple terms, Common Language Infrastructure (CLI) enables an
application program written in any commonly-used programming
languages to be run on any operating system using a common runtime
program rather than a specific for every language.

 The .NET Framework, .NET Core, and Mono are some


implementations of CLI.
Common Language Infrastructure
(CLI)
 The CLI includes the Common Type System (CTS) and
Common Language Specification (CLS). No matter which
programming language they are written in, CLI applications are
compiled into Intermediate Language (IL), which is further
compiled into the target machine language by the Common
Language Runtime (CLR) software.
Base Class Library
 The base class library encapsulates a large number of common
functions which can be used by the developers. They are the
foundational types and act as the base for all the .NET class
libraries. App-specific libraries will be built on top of BCL.

 They are developed with general implementations with a high-


performance policy such as low-latency, high throughput, low-
memory, and low-CPU usage. Features such as ADO.NET, XML
handling, Threading, Security, Diagnosis, etc., are part of the base
class library.

 BCL is a subset of Framework Class Library. It typically


includes classes in namespaces like System , System.Data,
System.Diagnostics , System.Resources, System.Globalization,
System.Text , System.Runtime.Serialization, etc.
FCL (Framework Class Library)
 The framework class library is a superset of the BCL classes. The
Framework class library (FCL) is a comprehensive collection of reusable
types including classes, interfaces and data types included in the .NET
Framework to provide access to system functionality.

 The .NET FCL forms the base on which applications, controls and
components are built in .NET. It can be used for developing applications
such as:
 console applications
 Windows GUI applications
 ASP.NET applications
 Windows and Web services
 workflow-enabled applications
 service oriented applications using Windows Communication
 XML Web services, etc.
FCL (Framework Class Library)
Common Type System (CTS)
 CTS specifies guidelines for declaring , using and managing types at run time

 CTS defines the basic data types that IL understands. Each .NET compliant
language should map its data types to these standard data types. This makes it
possible for the 2 languages to communicate with each other
 .NET supports many languages and every language has its own data type.
One language cannot understand data types of another language.

 For example: When we are creating an application in C#, we have int and
when we are creating an application in VB .NET, we have an integer. Here
CTS comes into play -- after the compilation, CTS converts int and
integer into the int32 structure.

 CTS can be specified in two types


 Value types
 Reference type
Common Type System (CTS)
Common Type System (CTS)
Metadata and Intermediate language
 Metadata is binary information describing your program that is stored
either in a common language runtime portable executable (PE) file or in
memory.

 When you compile your code into a PE file, metadata is inserted into one
portion of the file, and your code is converted to Microsoft intermediate
language (MSIL) and inserted into another portion of the file.

 Every type and member that is defined and referenced in a module or


assembly is described within metadata.

 When code is executed, the runtime loads metadata into memory and
references it to discover information about your code's classes, members,
inheritance, and so on.
Assemblies
 It is the smallest unit of deployment of a .net application and it
can be a .dll or an exe .
 Assembly is really a collection of types and resource information
that are built to work together and form a logical unit of
functionality.
 Assemblies are of two types:
 Static assemblies-they are stored in the PE files on disk

 Dynamic assemblies-Executes directly from memory without


being saved on disk. After execution it can be saved on disk
Assemblies
Assembly Content
 It is logical unit of four things:
 Manifest
 Type metadata
 MSIL code
 Set of resources such as bitmaps, JPEG files
Assemblies
Assembly Manifest
 It is information about what is contained in assembly
 An assembly manifest contains all the metadata needed to specify the
assembly's version requirements and security identity
 The assembly manifest can be stored in either a PE file (an .exe or .dll)
with Microsoft intermediate language (MSIL) code or in a standalone
PE file that contains only assembly manifest information.
Assemblies
Assembly Manifest Contents
Information Description

Assembly Name Specify name of assembly

Version Number Indicates major and minor version of assembly

Culture Information about language supported by assembly

Strong name info The public key from the publisher if the assembly has been given a
strong name.

List of all files in Contains hash token and name of each file contained in assembly
assembly

Type reference Information used by the runtime to map a type reference to the file
information that contains its declaration and implementation.

Information on A list of other assemblies that are statically referenced by the


referenced assemblies assembly. Each reference includes the dependent assembly's name,
assembly metadata (version, culture, operating system, and so on),
and public key, if the assembly is strong named.
Assemblies
Global Assembly Cache(GAC)
 Each computer where the common language runtime is installed
has a machine-wide code cache called the global assembly cache.

 The global assembly cache stores assemblies specifically


designated to be shared by several applications on the computer
otherwise it is kept private.

 You can deploy an assembly in GAC using following ways:


 An installer that is designed to work with GAC
 GAC tool known as Gucutil.exe
Assemblies
Strong Name Assemblies
 A strong Name Assembly is hash token that contains
Assembly’s identity -its simple text name, version number, and
culture information (if provided)—plus a public key and a digital
signature.

 Benefits of Strong Name Assembly


 Provides uniqueness to names by generating private key
 It ensure that content of Assembly do not change since last build
Assemblies
Private and shared assemblies

 An assembly is called private if it is used by a single application


If you have created dll containing business logic which should be
in the same folder in which client application has been installed.
This makes assembly private to your application

 Shared assemblies are those assemblies which are kept in GAC


so They can be used by multiple applications
Namespaces
 Namespaces are the way to organize .NET Framework Class
Library into a logical grouping according to their functionality

 The System Namespaces is the root for types in the .NET


Framework. We can uniquely identify any Class in the .NET
Framework Class Library (FCL ) by using the full Namespaces of
the class . All other namespaces comes under
this System namespace.
Namespaces
 List of Namespaces under system
 System
 System.Collection
 System.Data
 System.OleDb
 System.SqlClient
 System.Diagnostics
 System.IO
 System.Net
 System.Threading
 System.Web
 System.Windows.Forms
 System.Xml
Garbage Collection
In the common language runtime (CLR), the garbage
collector serves as an automatic memory manager. It
provides the following benefits:

 Enables you to develop your application without having to


free memory.
 Allocates objects on the managed heap efficiently.
 Reclaims objects that are no longer being used, clears their
memory, and keeps the memory available for future
allocations.
 Provides memory safety by making sure that an object cannot
use the content of another object.
Garbage Collection
 In .NET garbage collector runs in background. Garbage collector
is given low priority. When system find no space in managed
heap garbage collector gets high priority to collect all unwanted
objects
Versioning and side by side execution
Side-by-side execution is the ability to store and execute
multiple versions of an application or component on the same
computer.

This means that you can have multiple versions of the runtime,
and multiple versions of applications and components that use
a version of the runtime, on the same computer at the same
time.

Side-by-side execution gives you more control over what


versions of a component an application binds to, and more
control over what version of the runtime an application uses.
Versioning and side by side execution
End to DLL Hell
 Dll Hell refers to a set of problems caused when multiple
applications attempt to share a common component like a
dynamic link library (DLL).
 Suppose you install an application on system. This updates new
version of shared component. So new application works well but
old application doesn’t work because it was dependent previous
version of component
 The reason for this issue was that the version information about
the different components of an application was not recorded by
the system.
 This problem is not with .NET

You might also like