2 Net Framework Overview 120201085125 Phpapp01
-
Upload
partho-bora -
Category
Documents
-
view
222 -
download
0
Transcript of 2 Net Framework Overview 120201085125 Phpapp01
.NET Framework .NET Framework OverviewOverview
.NET Framework, CLR, MSIL, .NET Framework, CLR, MSIL, Assemblies, CTS, etc.Assemblies, CTS, etc.
Doncho MinkovDoncho Minkov
Telerik School AcademyTelerik School Academyschoolacademy.telerikschoolacademy.telerik
.com .com
Technical TrainerTechnical Trainerhttp://www.minkov.it http://www.minkov.it
Table of ContentsTable of Contents1.1. What isWhat is .NET.NET??
Microsoft .NET platform architectureMicrosoft .NET platform architecture2.2. What isWhat is .NET.NET FrameworkFramework??
.NET Framework Architecture.NET Framework Architecture3.3. Common Language Runtime (CLR)Common Language Runtime (CLR)4.4. Managed CodeManaged Code5.5. Intermediate LanguageIntermediate Language MSILMSIL6.6. Assemblies and MetadataAssemblies and Metadata7.7. .NET Applications.NET Applications
Table of ContentsTable of Contents (2) (2)8.8. Common Language Infrastructure Common Language Infrastructure
(CLI)(CLI) and integration of different and integration of different languageslanguages
Common Language Specification Common Language Specification (CLS)(CLS)
Common Type System (CTS)Common Type System (CTS)9.9. Framework Class LibraryFramework Class Library10.10. Integrated Development Integrated Development
EnvironmentEnvironment Visual StudioVisual Studio
.NET Framework.NET FrameworkMicrosoft's Platform Microsoft's Platform
for Application for Application DevelopmentDevelopment
What is the .NET What is the .NET PlatformPlatform??
The .NET platformThe .NET platform Microsoft's platform for software Microsoft's platform for software
developmentdevelopment Unified technology for development of Unified technology for development of
almost any kind of applicationsalmost any kind of applications GUI / Web / RIA / mobile / server / cloud / GUI / Web / RIA / mobile / server / cloud /
etc.etc. .NET platform versions.NET platform versions
.NET Framework.NET Framework Silverlight / Windows Phone 7Silverlight / Windows Phone 7 .NET Compact Framework.NET Compact Framework
What isWhat is .NET .NET Framework?Framework?
.NET Framework.NET Framework An environment for developing and An environment for developing and
executingexecuting .NET.NET applicationsapplications Unified programming modelUnified programming model, , set of set of
languages, class librarieslanguages, class libraries,, infrastructure, components and tools infrastructure, components and tools for application developmentfor application development
Environment for controlled execution Environment for controlled execution of managed codeof managed code
It is commonly assumed thatIt is commonly assumed that .NET platform == .NET Framework.NET platform == .NET Framework
..NET Framework NET Framework ComponentsComponents
Common Language RuntimeCommon Language Runtime (CLR) (CLR) Environment for controlled executionEnvironment for controlled execution of of
programmed codeprogrammed code – – like a virtual machine like a virtual machine ExecutesExecutes .NET.NET applicationsapplications
Framework Class LibraryFramework Class Library (FCL) (FCL) StandardStandard class library for .NET class library for .NET
developmentdevelopment Delivers basic functionality for developingDelivers basic functionality for developing::
XML, ADO.NET, LINQ, ASP.NET, WPF, WCF, XML, ADO.NET, LINQ, ASP.NET, WPF, WCF, WWF, Silverlight, Web services, Windows WWF, Silverlight, Web services, Windows Forms, Forms, ......
SDK, compilers and toolsSDK, compilers and tools
.NET Framework .NET Framework ArchitectureArchitecture
The OSThe OS manages themanages the resourcesresources, , the processes and the users of the processes and the users of the machinethe machine
Provides to the applications some Provides to the applications some services (threadsservices (threads, , I/O, GDI+, I/O, GDI+, DirectX, COM, COM+, MSMQ, IIS, DirectX, COM, COM+, MSMQ, IIS, WMI, …)WMI, …)
CLR is a separate process in the CLR is a separate process in the OSOS
Operating System (OS)Operating System (OS)
Operating System (OS)Operating System (OS)
Common Language Runtime (CLR)Common Language Runtime (CLR)
CLR managesCLR manages the the execution of the.NET codeexecution of the.NET code
Manages the memoryManages the memory, , concurrencyconcurrency, , securitysecurity, ..., ...
.NET Framework .NET Framework Architecture Architecture (2)(2)
CLRCLR
Operating System (OS)Operating System (OS)
Common Language Runtime (CLR)Common Language Runtime (CLR)Base Class Library (BCL)Base Class Library (BCL)
.NET Framework .NET Framework Architecture Architecture ((33))
Rich object-oriented library Rich object-oriented library with fundamental classeswith fundamental classes
Input-output, collections, Input-output, collections, text processing, networking,text processing, networking, securitysecurity, , multi-threadingmulti-threading, , ……
Operating System (OS)Operating System (OS)
Common Language Runtime (CLR)Common Language Runtime (CLR)Base Class Library (BCL)Base Class Library (BCL)
ADO.NET, LINQ and XML (Data Tier)ADO.NET, LINQ and XML (Data Tier)
.NET Framework .NET Framework Architecture Architecture ((44))
Database accessDatabase access ADO.NET, LINQ, LINQ-to-ADO.NET, LINQ, LINQ-to-
SQL and Entity FrameworkSQL and Entity Framework Strong XML supportStrong XML support
Operating System (OS)Operating System (OS)
Common Language Runtime (CLR)Common Language Runtime (CLR)Base Class Library (BCL)Base Class Library (BCL)
ADO.NET, LINQ and XML (Data Tier)ADO.NET, LINQ and XML (Data Tier)
.NET Framework .NET Framework Architecture Architecture ((55))
WCF and WWF (Communication and Workflow Tier)WCF and WWF (Communication and Workflow Tier)
Windows Communication Windows Communication Foundation (WCF) and Foundation (WCF) and Windows Workflow Windows Workflow Foundation (WWF) for Foundation (WWF) for the SOA worldthe SOA world
Operating System (OS)Operating System (OS)
Common Language Runtime (CLR)Common Language Runtime (CLR)Base Class Library (BCL)Base Class Library (BCL)
ADO.NET, LINQ and XML (Data Tier)ADO.NET, LINQ and XML (Data Tier)
.NET Framework .NET Framework Architecture Architecture ((66))
WCF and WWF (Communication and Workflow Tier)WCF and WWF (Communication and Workflow Tier)
ASP.NETASP.NETWeb Forms, MVC, AJAXWeb Forms, MVC, AJAXMobile Internet ToolkitMobile Internet Toolkit
WindowsWindowsFormsForms WPFWPF SilverlightSilverlight
User interface technologies: User interface technologies: Web based, Windows GUI, WPF, Web based, Windows GUI, WPF, Silverlight, mobile, …Silverlight, mobile, …
Operating System (OS)Operating System (OS)
Common Language Runtime (CLR)Common Language Runtime (CLR)Base Class Library (BCL)Base Class Library (BCL)
ADO.NET, LINQ and XML (Data Tier)ADO.NET, LINQ and XML (Data Tier)
.NET Framework .NET Framework Architecture Architecture ((77))
WCF and WWF (Communication and Workflow Tier)WCF and WWF (Communication and Workflow Tier)
ASP.NETASP.NETWeb Forms, MVC, AJAXWeb Forms, MVC, AJAXMobile Internet ToolkitMobile Internet Toolkit
WindowsWindowsFormsForms WPFWPF SilverlightSilverlight
C#C# C++C++VB.NETVB.NET J#J# F#F# JScriptJScriptPerlPerlDelphiDelphi ……
Programming language on your Programming language on your flavor!flavor!
Common Common Language Language
RuntimeRuntime ( (CLRCLR))The Heart of .NET The Heart of .NET FrameworkFramework
Common Language Common Language RuntimeRuntime ( (CLRCLR))
Managed execution environmentManaged execution environment Controls the execution of Controls the execution of
managedmanaged . .NET programming codeNET programming code Something like virtual machineSomething like virtual machine
Like the Java Virtual Machine (JVM)Like the Java Virtual Machine (JVM) Not an interpreterNot an interpreter
Compilation on-demand is usedCompilation on-demand is used Known as Known as Just In Time (JIT) compilationJust In Time (JIT) compilation
Possible compilation in advance Possible compilation in advance (Ngen)(Ngen)
ResponsibilitiesResponsibilities ofof CLR CLR Execution of theExecution of the IL codeIL code andand the JIT the JIT
compilationcompilation Managing memory and application Managing memory and application
resourcesresources Ensuring type safetyEnsuring type safety Interaction with the OSInteraction with the OS Managing securityManaging security
Code access securityCode access security Role-based securityRole-based security
ResponsibilitiesResponsibilities ofof CLR CLR (2)(2)
Managing exceptionsManaging exceptions Managing concurrency Managing concurrency – – controlling controlling
the parallel execution of the parallel execution of application application threadsthreads
Managing application domains and Managing application domains and their isolationtheir isolation
Interaction with unmanaged codeInteraction with unmanaged code SupportingSupporting debug /debug /
profile of .NET code profile of .NET code
CLR ArchitectureCLR Architecture
Class LoaderClass Loader
IL to NativeIL to NativeJIT CompilerJIT Compiler
CodeCodeManagerManager
GarbageGarbageCollectorCollector
Security EngineSecurity Engine Debug EngineDebug Engine
Type CheckerType Checker Exception ManagerException Manager
Thread SupportThread Support COM MarshalerCOM Marshaler
Base Class Library SupportBase Class Library Support
Managed CodeManaged Code CLR executed code is called CLR executed code is called managed codemanaged code Represents programming code in the low Represents programming code in the low
level language level language MSILMSIL (MS Intermediate (MS Intermediate Language)Language)
Contains metadataContains metadata Description of classesDescription of classes, , interfacesinterfaces, , propertiesproperties, ,
fieldsfields, , methodsmethods, , parameters, etc.parameters, etc. ProgramsPrograms, , written in anywritten in any .NET language are.NET language are
Compiled to managed codeCompiled to managed code (MSIL)(MSIL) Packaged as assemblies (Packaged as assemblies (.exe.exe or or ..dlldll files) files)
Managed Code Managed Code (2)(2) Object-orientedObject-oriented SecureSecure ReliableReliable
Protected from Protected from irregularirregular use of types use of types ((type-safe)type-safe)
Allows integration between Allows integration between components and data types of components and data types of different programming languagesdifferent programming languages
Portable between different platformsPortable between different platforms Windows, Linux, Max OS X, etc.Windows, Linux, Max OS X, etc.
Unmanaged (Win32) Unmanaged (Win32) CodeCode
No protection of memory and type-No protection of memory and type-safetysafety Reliability problemsReliability problems Safety problemsSafety problems
Doesn’t contain metadataDoesn’t contain metadata Needs additional overhead like (e.g. use Needs additional overhead like (e.g. use
COM)COM) Compiled to machine-dependent codeCompiled to machine-dependent code
Need of different versions for different Need of different versions for different platformsplatforms
Hard to be ported to other platformsHard to be ported to other platforms
Memory ManagementMemory Management CLR manages memory automatically CLR manages memory automatically
Dynamically loadedDynamically loaded objects are stored objects are stored in the in the managed heapmanaged heap
Unusable objects are automatically Unusable objects are automatically cleaned up by the cleaned up by the garbage collectorgarbage collector
Some of the big problems are solvedSome of the big problems are solved Memory leaksMemory leaks Access to freed or unallocated memoryAccess to freed or unallocated memory
Objects are accessed through a Objects are accessed through a referencereference
Intermediate LanguageIntermediate Language ((MSILMSIL, , ILIL,, CIL) CIL)
Low level languageLow level language ( (machine languagemachine language)) for the .NET CLRfor the .NET CLR
Has independent set of CPU instructionsHas independent set of CPU instructions Loading and storing data, calling methods Loading and storing data, calling methods
Arithmetic and logical operationsArithmetic and logical operations Exception handlingException handling Etc.Etc.
MSIL is converted to instructions for the MSIL is converted to instructions for the current physical CPU by the JIT compilercurrent physical CPU by the JIT compiler
SampleSample MSIL ProgramMSIL Program
.method private hidebysig static void Main() cil .method private hidebysig static void Main() cil managedmanaged{{ .entrypoint.entrypoint // Code size 11 (0xb)// Code size 11 (0xb) .maxstack 8.maxstack 8 ldstr "Hello, world!"ldstr "Hello, world!" call voidcall void [mscorlib]System.Console::WriteLine(string)[mscorlib]System.Console::WriteLine(string) retret} // end of method HelloWorld::Main} // end of method HelloWorld::Main
Compilation and Compilation and ExecutionExecution
CompilationCompilation
ExecutionExecution
JIT JIT compilecompile
rr
MachinMachine codee code
MSILMSILCodeCode
MetadataMetadataSourcSource codee code
LanguagLanguage e
compilercompiler
AssemAssemblybly
(.EXE (.EXE oror
.DLL .DLL file)file)
When given When given method is method is called for called for the first the first
timetimePre-Pre-compilation compilation during the during the
install install (NGEN)(NGEN)
.NET Applications.NET ApplicationsAssemblies, Metadata and Assemblies, Metadata and
ApplicationsApplications
.NET Assemblies.NET Assemblies .NET assemblies:.NET assemblies:
Self-containing .NET componentsSelf-containing .NET components Stored in .DLL and .EXE filesStored in .DLL and .EXE files
Contain list of classes, types and Contain list of classes, types and resourcesresources
Smallest deployment unit in CLRSmallest deployment unit in CLR Have unique version numberHave unique version number
.NET deployment model.NET deployment model No version conflicts (forget the "DLL hell")No version conflicts (forget the "DLL hell") Supports side-by-side execution of Supports side-by-side execution of
different versions of the same assemblydifferent versions of the same assembly
Metadata in the Metadata in the AssembliesAssemblies
Metadata in the .NET assembliesMetadata in the .NET assemblies Data about data contained in the Data about data contained in the
assemblyassembly Integral part of the assemblyIntegral part of the assembly Generated by the .NET languages Generated by the .NET languages
compilercompiler Describes all classes, their class Describes all classes, their class
members, versions, resources, etc.members, versions, resources, etc.
Metadata in AssembliesMetadata in AssembliesType DescriptionType Description
Assembly DescriptionAssembly Description
Classes, interfaces, inner types, base classes, implemented interfaces, member fields, properties, methods, method parameters, return value,attributes, etc.
Dependencies on other assembliesDependencies on other assembliesSecuritySecurity permissions permissionsExported typesExported types
[digital[digitalsignature]signature]
NameNameVersionVersionLocalizationLocalization
..NETNET ApplicationsApplications Configurable executable .NET unitsConfigurable executable .NET units Consist of one or more assembliesConsist of one or more assemblies Installed by "copy / paste"Installed by "copy / paste"
No complex registration of componentsNo complex registration of components Different applications use different Different applications use different
versions of common assembliesversions of common assemblies No conflicts due to their "strong name"No conflicts due to their "strong name"
Easy installationEasy installation, , un-installation and un-installation and updateupdate
Common Type System Common Type System (CTS)(CTS)
CTS defines the CLRCTS defines the CLR supported supported types of data and the operations types of data and the operations over themover them
Ensures data level compatibility Ensures data level compatibility between different .NETbetween different .NET languageslanguages E.g. E.g. stringstring in in C#C# is the same likeis the same like StringString in in VB.NETVB.NET and inand in J#J#
Value types and reference typesValue types and reference types All types derive fromAll types derive from System.ObjectSystem.Object
..NET LanguagesNET Languages .NET languages by Microsoft.NET languages by Microsoft
C#, VB.NET, Managed C++, J#, F#, C#, VB.NET, Managed C++, J#, F#, JScriptJScript
.NET languages.NET languages by third partiesby third parties Object Pascal, Perl, Python, COBOL, Object Pascal, Perl, Python, COBOL,
Haskell, Oberon, Scheme, Smalltalk…Haskell, Oberon, Scheme, Smalltalk… Different languages can be mixed in Different languages can be mixed in
a single applicationa single application Cross-language inheritance of types Cross-language inheritance of types
and exception handlingand exception handling
C# LanguageC# Language C# is mixture between C++, Java and C# is mixture between C++, Java and
DelphiDelphi Fully object-oriented by designFully object-oriented by design
Component-oriented programming Component-oriented programming modelmodel ComponentsComponents, , properties and eventsproperties and events No header files like C/C++No header files like C/C++ Suitable forSuitable for GUIGUI andand WebWeb applicationsapplications XML based documentationXML based documentation
InIn C# all data types are objectsC# all data types are objects Example: Example: 5.ToString()5.ToString() is a valid call is a valid call
C# Language – ExampleC# Language – Example C# is standardized byC# is standardized by ECMA and ECMA and
ISOISO Example of C# program:Example of C# program:
using System;using System;
class NumbersFrom1to100class NumbersFrom1to100{{ static void Main()static void Main() {{ for (int i=1; i<=100; i++)for (int i=1; i<=100; i++) { { Console.WriteLine(i);Console.WriteLine(i); }} }}}}
Framework Class Framework Class Library (FCL)Library (FCL)
Standard Out-of-the-box .NET APIsStandard Out-of-the-box .NET APIs
Framework Class Framework Class Library (FCL)Library (FCL)
Framework Class Library is the Framework Class Library is the standard .NET Framework library of out-standard .NET Framework library of out-of-the-box reusable classes and of-the-box reusable classes and components (APIs)components (APIs)
Base Class Library (BCL)Base Class Library (BCL)
ADO.NET, LINQ and XML (Data Tier)ADO.NET, LINQ and XML (Data Tier)
WCF and WWF (Communication and Workflow Tier)WCF and WWF (Communication and Workflow Tier)
ASP.NETASP.NETWeb Forms, MVC, AJAXWeb Forms, MVC, AJAXMobile Internet ToolkitMobile Internet Toolkit
WindowsWindowsFormsForms WPFWPF SilverlightSilverlight
FCL NamespacesFCL Namespaces
ADO.NET, LINQ and XML (Data Tier)ADO.NET, LINQ and XML (Data Tier)
WCF and WWF (Communication and Workflow Tier)WCF and WWF (Communication and Workflow Tier)
ASP.NETASP.NETWeb Forms, MVC, AJAXWeb Forms, MVC, AJAXMobile Internet ToolkitMobile Internet Toolkit
WindowsWindowsFormsForms WPF & SilverlightWPF & Silverlight
System.WebSystem.Web
System.Web.MvcSystem.Web.Mvc
System.WindowSystem.Windows.Formss.Forms
System.DrawinSystem.Drawingg
System.WindowsSystem.Windows
System.Windows.MediaSystem.Windows.Media
System.Windows.MarkupSystem.Windows.Markup
System.ServiceModelSystem.ServiceModel System.ActivitiesSystem.Activities System.WorkflowSystem.Workflow
System.DataSystem.Data System.LinqSystem.Linq
System.Data.LinqSystem.Data.Linq
System.XmlSystem.Xml
System.Xml.LinqSystem.Xml.Linq System.Data.EntitySystem.Data.Entity
Visual Studio IDEVisual Studio IDEPowerful Development Powerful Development Environment for .NETEnvironment for .NET
Visual StudioVisual Studio Visual Studio is powerful IntegratedVisual Studio is powerful Integrated
Development Environment (IDE) for .NET Development Environment (IDE) for .NET DevelopersDevelopers Create, edit, compile and run .NET Create, edit, compile and run .NET
applicationsapplications Different languagesDifferent languages – – C#, CC#, C++, ++, VB.NET,VB.NET, J#, J#,
…… FlexibleFlexible code editorcode editor PowerfulPowerful debuggerdebugger Integrated with SQL ServerIntegrated with SQL Server andand IISIIS Strong support of Web services, WCF and Strong support of Web services, WCF and
WWFWWF
Visual Studio Visual Studio (2)(2) Visual programmingVisual programming
Component-orientedComponent-oriented, , event basedevent based Managed and unmanaged codeManaged and unmanaged code Helpful wizards and editorsHelpful wizards and editors
Windows Forms DesignerWindows Forms Designer WCF / Silverlight DesignerWCF / Silverlight Designer ASP.NET Web Forms DesignerASP.NET Web Forms Designer ADO.NET / LINQ-to-SQL / XML Data ADO.NET / LINQ-to-SQL / XML Data
DesignerDesigner Many third party extensionsMany third party extensions