Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Everything about

Microsoft.NET
Framework

by Sandeep Soni
.NET Enterprise Vision
Users
Any device,
Any place,
Any time

XML Web
Services
Integrate business
Authentication applications and
Scheduling processes
Notification

Back Office
Heterogeneous
application and
server
infrastructure

Customer Sales
ERP & Billing Service
Category of Programmers
 System Programmers – One who programs
directly for a given hardware eg: Device Drivers
or extremely low level o/p services.
 Application Programmers – One who programs
applications used by people for their
requirements – eg: Calculator, Calendar, MS-
Office like packages, Accounting Packages etc…
 .NET is for Application programming and not for
System programming.
Definitions

Platform is an environment for developing and


executing application.
Framework is ready to use collection of Classes
and Interfaces used for developing a particular
type of application.
What is a Platform?

Assembly Code

MS.NET MS.NET JAVA


Applications Framework
H/W JRE Applications

Operating System

C/ C++ Applications
What is .NET?

MS.Net is a Framework built on open internet


protocols & standards with tools and services that
meld computing and communication in new ways
It’s an environment for developing and running
software applications featuring ease of development
of web based services, rich standard runtime services
available to components written in variety of
programming languages & provides inter language &
inter machine inoperability
Framework Components
 MS.NET Framework Runtime
 Used for both Development and Production of .NET
applications
 MS.NET Framework SDK
 Mostly used only for Development of .NET application
 Visual Studio.NET
 IDE and RAD Tool for Developing .NET applications
 Not needed on Production machine
 Common environment for multiple languages like VB.NET, C#,
VC++
 Can be used any type of MS.NET Application
 Can be used also for non .net based applications like PHP
pages. For this we need a plug-in to be installed over Studio.
.Net Framework in Context
MS.NET Framework Versions

 Version 1.0 in Year 2002


 Version 1.1 in Year 2003
 Version 2.0 in Year 2005
 Version 3.0 in Year 2006
 Version 3.5 in Year 2007
 Version 4.0 in Year 2010
 Version 4.5 in Year 2012
 All versions can be installed side by side
on same machine.
Versions Dependency

 1.0 is a standalone version


 1.1 is also a standalone version
 2.0 is also a standalone version
 3.0 is installed over 2.0
 3.5 is installed over 3.0
 4.0 is also standalone versions.
 When .NET 4.5 is installed it effectively replaces
.NET 4.0 on the machine
Version Compatibility

 Doesn't support Forward or Backward


compatibility.
 The version used on development machine
and production machine must be same.
 If 1.1 has been used for development and on
the production machine even if 2.0 is installed
and if 1.1 is not, then the application will not
work.
The Core of .NET Framework
 Application Services
 Framework / Base Class Library
 Provides the core functionality:
ASP.NET, Web Services, ADO.NET, Windows
Forms, IO, XML, etc.
 Common Language Runtime
 Garbage collection
 Language integration
 Multiple versioning support (no more DLL hell!)
 Integrated security
MS.NET Framework Stack

C++ C# VB Perl J# …
ASP .NET Windows
Web Forms Web Services
Forms
Mobile Internet Toolkit

ADO .NET and XML

.NET Framework (Base Class Library)

Common Language Runtime

Operating System
TYPES OF MS.NET APPLICATION

 Console Based Applications (e.g. Compiler)


 Windows GUI Application using WinForms
 GUI Rich Windows Application (WPF)
 Windows Services
 ASP.NET Web Applications (ASPX / MVC)
 SOA using WCF
 Mobile / Smart Device Applications
Understanding

Base Class Libraries (BCL)


or
Framework Class Libraries (FCL)
Base Class Library?

The .NET base class library is a collection of object-


oriented types and interfaces that provide object
models and services for many of the complex
programming tasks we routinely face during
application development
Base Class Library – Advantages

 Language Independent.
 Completely Object Oriented.
 Most of the types presented by the .NET base
class library are fully extensible, allowing you to
build types that incorporate your own
functionality
 Packaged with .NET Framework in the form of
DLL files.
 Well optimized for performance
Base Class Library includes

 Data types, conversions, formatting


 Collections: ArrayList, Hashtable, etc.
 Globalization: Cultures, sorting, etc.
 I/O: Binary and text streams, files, etc.
 Networking: HTTP, TCP/IP sockets, etc.
 Reflection: Metadata and IL emit
 Security: Permissions, cryptography
 Text: Encodings, regular expressions
What is Namespace?

 A namespace is a logical collection of classes


and other types with unique name.
 The structure of the namespace is like a tree
where all the related classes are like leaves
 All BCL begin with the namespace “System”.
Base Class Library Namespaces
System
Collections Security
Configuration ServiceProcess
Diagnostics Text
Globalization Threading
IO Runtime
Net InteropServices
Reflection Remoting
Resources Serialization
Understanding
MSIL and PE
.NET Languages

 Languages provided by Microsoft


 C++, C#, J#, VB.NET, Jscript.NET & F#
 Third-parties languages
 Perl, Python, Pascal, APL, COBOL, Eiffel,
Haskell, ML, Oberon, Scheme, Smalltalk…
Code Compilation and Execution
Compilation
Also called
Source Language Code
Assembly
Code Compiler MSIL
Metadata (.EXE or
.DLL file)

Before
installation or the
first time each
Execution method is called

Native JIT
Code Compiler
PE – Portable Executable

 Is a Microsoft Win32 compatible format file for .Net


applications which contains the MSIL code and Metadata in
binary form.
 It has the extension .EXE or .DLL
 PE is based on all Win32 platforms compatible COFF (Common
Object File Format) specification.
MSIL

It stands for Microsoft Intermediate Language.

MSIL instructions are platform independent


instructions.

MSIL is an intermediate instruction set which is


independent of processor and hardware.
Example of MSIL Code

.assembly MyAssembly {}
.class MyApp
{
.method static void Main()
{
.entrypoint
ldstr Hello, IL!"
call void System.Console::WriteLine("Hello")
ret
}
}
Metadata

 Metadata describes every type and member defined in your


code in a language-neutral manner
 Metadata stores the following information:
 Description of the assembly
 Name, Version, Culture, Public Key
 Exported Types
 Other Assemblies that this assembly is dependent upon
 Description of types.
 Name, Visibility, base class and interface implemented
 Members – Fields, Properties, Methods, events and nested types
 Attributes: Additional descriptive elements that modify types and
members
Compiler & Assembler

Language
Source Language Compiler Portable Executable
Code (MSIL - Binary Format)

ILASM.EXE
Reverse Engineering

ILDASM.EXE

MSIL
(Text Format)
COMMON
LANGUAGE RUNTIME
(CLR)
What is the Difference between

Street DOG
and
Pet DOG?
Managed Code

 Code that targets the CLR is referred to as


managed code
 All managed code has the features of the CLR
 Object-oriented
 Type-safe
 Cross-language integration
 Cross language exception handling
 Managed code is represented in special
Intermediate Language (IL)
CLR Advantages

 High Performance Applications


 Vastly simplified development.
 Seamless integration of the code written in various
languages.
 Evidence-based security with code identity.
 Assembly-based deployment that eliminates DLL Hell.
 Side-by-side versioning of reusable components.
 Code reuse through implementation inheritance.
 Automatic object lifetime management.
 Self describing objects.
Components in CLR

 Code Execution
 Common Type System (CTS)
 Automatic Memory Management
 JIT Compiler
 Garbage Collector
 Security Manager
 Class Loader
 Interoperate with COM Components and DLLs
Common Type System
 The common Type System defines how types are
declared, used, and managed in the runtime, and is
also an important part of the runtime's support for
cross-language integration, type safety and high
performance applications.
 Supported Types
 Classes
 Structures
 Enumerations
 Interfaces
 Delegates
Automatic Memory Management
 The CLR manages memory for managed code
 All allocations of objects and buffers made from a
Managed Heap
 Unused objects and buffers are cleaned up
automatically through Garbage Collection
 Some of the worst bugs in software development are
not possible with managed code
 Memory Leakages
 Dangling Pointers
 Reading of uninitialized variables
 Pointerless environment
JIT Compiler

 CLR compiles IL in just-in-time (JIT) manner –


each function is compiled just before execution.
Also the JIT code stays in memory for subsequent
calls
 NGen.EXE (Native Generator) is used for
compiling all the MSIL code in PE file into Native
code. This is done before the code is executed or
during the deployment of PE on target machine.
This way even the first time execution of code is
fast as it doesn’t need any more runtime
compilation
.NET Framework on Linux

 Mono Project
 Open Source C# compiler, CLR and Framework Class Library
 Runs on various platforms and hardware:
 Linux, Unix, FreeBSD, Windows – JIT-compiler for x86
 s390, SPARC, PowerPC – interpreter for these hardware
architectures
 Supports also:
 ADO.NET and XML
 Windows Forms (not fully)
 ASP.NET
 Web Services
Thank You

You might also like