Microsoft .NET Framework

49

description

Microsoft .NET Framework. Overview. Svetlin Nakov. http:// www.nakov.com. Software Development Consultant, Part-time Computer Science Lecturer. Sofia University “St. Kliment Ohridski”. .NET Enterprise Vision. Users Any device, Any place, Any time. - PowerPoint PPT Presentation

Transcript of Microsoft .NET Framework

Page 1: Microsoft  .NET Framework
Page 2: Microsoft  .NET Framework

Microsoft Microsoft .NET Framework.NET Framework

OverviewOverview

Svetlin NakovSvetlin Nakov

Software Development Consultant,Software Development Consultant,Part-time Computer Science LecturerPart-time Computer Science Lecturer

Sofia UniversitySofia University“St. Kliment Ohridski”“St. Kliment Ohridski”

http://www.nakov.comhttp://www.nakov.com

Page 3: Microsoft  .NET Framework

.NET Enterprise Vision

ERP & BillingCustomerService

Sales

UsersAny device,Any place,Any time

XML Web ServicesIntegrate business applications and processes

Back OfficeHeterogeneous application and server infrastructure

SchedulingAuthentication

Notification

Page 4: Microsoft  .NET Framework

.NET Framework.NET Framework.NET Framework.NET Framework

Programming model for .NETProgramming model for .NET Platform for running .NET code in a Platform for running .NET code in a

managed environmentmanaged environment Provides a very good environment Provides a very good environment

to develop networked applications to develop networked applications and Web Servicesand Web Services

Provides programming API and Provides programming API and unified language-independent unified language-independent development frameworkdevelopment framework

Code runs on multiple platforms Code runs on multiple platforms (Windows, Linux, FreeBSD, …)(Windows, Linux, FreeBSD, …)

Programming model for .NETProgramming model for .NET Platform for running .NET code in a Platform for running .NET code in a

managed environmentmanaged environment Provides a very good environment Provides a very good environment

to develop networked applications to develop networked applications and Web Servicesand Web Services

Provides programming API and Provides programming API and unified language-independent unified language-independent development frameworkdevelopment framework

Code runs on multiple platforms Code runs on multiple platforms (Windows, Linux, FreeBSD, …)(Windows, Linux, FreeBSD, …)

Page 5: Microsoft  .NET Framework

The Core of .NETThe Core of .NET Framework: Framework: FCL & CLRFCL & CLR Common Language RuntimeCommon Language Runtime

Garbage collectionGarbage collection Language integrationLanguage integration Multiple versioning support for Multiple versioning support for

assemblies (no more DLL hell!)assemblies (no more DLL hell!) Integrated securityIntegrated security

Framework Class LibraryFramework Class Library Provides the core functionality:Provides the core functionality:

ASP.NET, Web Services, ADO.NET, ASP.NET, Web Services, ADO.NET, Windows Forms, IO, XML, etc.Windows Forms, IO, XML, etc.

Page 6: Microsoft  .NET Framework

.NET Framework.NET Framework Common Language RuntimeCommon Language Runtime

Operating SystemOperating System

Common Language RuntimeCommon Language Runtime

CLR manages code execution CLR manages code execution at runtimeat runtime

Memory management, thread Memory management, thread management, etc.management, etc.

Code-based securityCode-based security Role-based securityRole-based security

Page 7: Microsoft  .NET Framework

.NET Framework.NET Framework Base Class LibraryBase Class Library

Operating SystemOperating System

Common Language RuntimeCommon Language Runtime

.NET Framework (Base Class Library).NET Framework (Base Class Library)

Object-oriented collection of Object-oriented collection of reusable typesreusable types

Collections, I/O, Strings, …Collections, I/O, Strings, …

Page 8: Microsoft  .NET Framework

.NET Framework.NET Framework Data Access LayerData Access Layer

Operating SystemOperating System

Common Language RuntimeCommon Language Runtime

.NET Framework (Base Class Library).NET Framework (Base Class Library)

ADO .NET and XMLADO .NET and XML

Access relational databasesAccess relational databases Disconnected data modelDisconnected data model Work with XMLWork with XML

Page 9: Microsoft  .NET Framework

.NET Framework.NET Framework ASP.NET & Windows FormsASP.NET & Windows Forms

Operating SystemOperating System

Common Language RuntimeCommon Language Runtime

.NET Framework (Base Class Library).NET Framework (Base Class Library)

ADO .NET and XMLADO .NET and XML

ASP .NETASP .NETWeb Forms Web ServicesWeb Forms Web Services

Mobile Internet ToolkitMobile Internet Toolkit

WindowsWindowsFormsForms

Create application’s front-end – Create application’s front-end – Web-based user interface, Web-based user interface, Windows GUI, Web services, …Windows GUI, Web services, …

Page 10: Microsoft  .NET Framework

.NET Framework.NET Framework Programming LanguagesProgramming Languages

Operating SystemOperating System

Common Language RuntimeCommon Language Runtime

.NET Framework (Base Class Library).NET Framework (Base Class Library)

ADO .NET and XMLADO .NET and XML

ASP .NETASP .NETWeb Forms Web ServicesWeb Forms Web Services

Mobile Internet ToolkitMobile Internet Toolkit

WindowsWindowsFormsForms

C++C++ C#C# VB.NETVB.NET PerlPerl J#J# ……

Use your favorite languageUse your favorite language

Page 11: Microsoft  .NET Framework

.NET Framework.NET Framework Common Language SpecificationCommon Language Specification

Operating SystemOperating System

Common Language RuntimeCommon Language Runtime

.NET Framework (Base Class Library).NET Framework (Base Class Library)

ADO .NET and XMLADO .NET and XML

ASP .NETASP .NETWeb Forms Web ServicesWeb Forms Web Services

Mobile Internet ToolkitMobile Internet Toolkit

WindowsWindowsFormsForms

Common Language SpecificationCommon Language SpecificationC++C++ C#C# VBVB PerlPerl J#J# ……

Page 12: Microsoft  .NET Framework

.NET Framework.NET Framework Visual Studio .NETVisual Studio .NET

Operating SystemOperating System

Common Language RuntimeCommon Language Runtime

.NET Framework (Base Class Library).NET Framework (Base Class Library)

ADO .NET and XMLADO .NET and XML

ASP .NETASP .NETWeb Forms Web ServicesWeb Forms Web Services

Mobile Internet ToolkitMobile Internet Toolkit

WindowsWindowsFormsForms

Common Language SpecificationCommon Language Specification

C++C++ C#C# VBVB PerlPerl J#J# ……

Visu

al S

tud

io .N

ET

Visu

al S

tud

io .N

ET

Page 13: Microsoft  .NET Framework

Multiple Language SupportMultiple Language Support

IL (MSIL or CIL) – Intermediate LanguageIL (MSIL or CIL) – Intermediate Language It is low-level (machine) language, like It is low-level (machine) language, like

Assembler, but is Object-orientedAssembler, but is Object-oriented CTS is a rich type system built into the CLRCTS is a rich type system built into the CLR

Implements various types (Implements various types (intint, float, string, …), float, string, …) And operations on those typesAnd operations on those types

CLS is a set of specifications that all CLS is a set of specifications that all languages and libraries need to followlanguages and libraries need to follow This will ensure interoperability between This will ensure interoperability between

languageslanguages

Page 14: Microsoft  .NET Framework

Example of MSIL CodeExample of MSIL Code

.method private hidebysig static void Main() .method private hidebysig static void Main() cil managedcil managed

{{ .entrypoint.entrypoint // Code size 11 (0xb)// Code size 11 (0xb) .maxstack 8.maxstack 8 IL_0000: ldstr "Hello, world!"IL_0000: ldstr "Hello, world!" IL_0005: call void IL_0005: call void

[mscorlib]System.Console::WriteLine(string)[mscorlib]System.Console::WriteLine(string) IL_000a: retIL_000a: ret} // end of method HelloWorld::Main} // end of method HelloWorld::Main

Page 15: Microsoft  .NET Framework

.NET Languages.NET Languages Languages provided by MicrosoftLanguages provided by Microsoft

C++, C#, J#, VB.NET, C++, C#, J#, VB.NET, JScriptJScript Third-parties languagesThird-parties languages

Perl, Python, Pascal, APL, COBOL, Eiffel, Perl, Python, Pascal, APL, COBOL, Eiffel, Haskell, ML, Oberon, Scheme, Smalltalk…Haskell, ML, Oberon, Scheme, Smalltalk…

Advanced multi-language featuresAdvanced multi-language features Cross-language inheritance and Cross-language inheritance and

exceptions handlingexceptions handling Single project can share code written in Single project can share code written in

multiple languagesmultiple languages Integration is built in, not bolted onIntegration is built in, not bolted on

No additional rules or API to learnNo additional rules or API to learn

Page 16: Microsoft  .NET Framework

C# LanguageC# Language Mixture between C++, Java and DelphiMixture between C++, Java and Delphi Component-orientedComponent-oriented

Properties, Methods, EventsProperties, Methods, Events Attributes, XML documentationAttributes, XML documentation All in one place, no header files, IDL, etc.All in one place, no header files, IDL, etc. Can be embedded in WebCan be embedded in Web applicationsapplications

Everything really is an objectEverything really is an object Primitive types aren’t magic, e.g.Primitive types aren’t magic, e.g.

5.ToString()5.ToString() is valid is valid Unified type system == Deep simplicityUnified type system == Deep simplicity Good extensibility and reusabilityGood extensibility and reusability

Page 17: Microsoft  .NET Framework

C# Language – ExampleC# Language – Example

using System;using System;

class HelloWorldclass HelloWorld{{

public static void main()public static void main(){{

Console.WriteLine(“Hello, Console.WriteLine(“Hello, world!”);world!”);}}

}}

Page 18: Microsoft  .NET Framework

Code Compilation and ExecutionCode Compilation and ExecutionCode Compilation and ExecutionCode Compilation and Execution

CompilationCompilation

- Install time - Install time precompilationprecompilation - Install time - Install time precompilationprecompilation

ExecutionExecution

JIT JIT CompilerCompiler

NativeNativeCodeCode

MSILMSILCodeCode

MetadataMetadata

Source Source CodeCode

Language Language CompilerCompiler

Also called Also called AssemblyAssembly(.EXE or(.EXE or.DLL file).DLL file)

Also called Also called AssemblyAssembly(.EXE or(.EXE or.DLL file).DLL file)

- First time each - First time each method is method is calledcalled

- First time each - First time each method is method is calledcalled

Page 19: Microsoft  .NET Framework

VS.NET – Single Development VS.NET – Single Development Environment & Skill SetEnvironment & Skill Set From Visual Studio.NET you can:From Visual Studio.NET you can:

Write codeWrite code Design user interfaceDesign user interface Study documentationStudy documentation ExecuteExecute, , test and deploytest and deploy DebugDebug

Same tools for all languagesSame tools for all languages Same tools for all platformsSame tools for all platforms Same tools for all technologiesSame tools for all technologies

Page 20: Microsoft  .NET Framework

Visual Studio .NETVisual Studio .NET

Page 21: Microsoft  .NET Framework

The .NET Framework LibraryThe .NET Framework Library

Base Class LibraryBase Class Library

ADO.NET and XMLADO.NET and XML

Web Forms Web ServicesWeb Forms Web ServicesMobile Internet ToolkitMobile Internet Toolkit

WindowsWindowsFormsForms

ASP.NETASP.NET

Page 22: Microsoft  .NET Framework

System System

GlobalizationGlobalization

DiagnosticsDiagnostics

ConfigurationConfiguration

CollectionsCollections

ResourcesResources

ReflectionReflection

NetNet

IOIO

ThreadingThreading

TextText

ServiceProcessServiceProcess

SecuritySecurity RuntimeRuntimeInteropServicesInteropServices

RemotingRemoting

SerializationSerialization

System.DataSystem.Data

DesignDesign

ADOADO

SQLTypesSQLTypes

SQLSQL

System.XmlSystem.Xml

XPathXPath

XSLTXSLT SerializationSerialization

.NET Framework Namespaces.NET Framework NamespacesSystem.WebSystem.Web

ConfigurationConfiguration SessionStateSessionState

CachingCaching SecuritySecurity

ServicesServices UIUIHtmlControlsHtmlControls

WebControlsWebControls

DescriptionDescription

DiscoveryDiscovery

ProtocolsProtocols System.DrawingSystem.Drawing

ImagingImaging

Drawing2DDrawing2D

TextText

PrintingPrinting

System.WinFormsSystem.WinForms

DesignDesign ComponentModelComponentModel

Page 23: Microsoft  .NET Framework

Base Class Library NamespacesBase Class Library Namespaces

SystemSystem

ThreadingThreading

TextText

ServiceProcessServiceProcess

SecuritySecurity

ResourcesResources

ReflectionReflection

NetNet

IOIO

GlobalizationGlobalization

DiagnosticsDiagnostics

ConfigurationConfiguration

CollectionsCollections

RuntimeRuntime

SerializationSerialization

RemotingRemoting

InteropServicesInteropServices

Page 24: Microsoft  .NET Framework

Base Class LibraryBase Class Library

Data types, conversions, formattingData types, conversions, formatting Collections: Collections: ArrayList, HashtableArrayList, Hashtable, etc., etc. Globalization: Cultures, sorting, etc.Globalization: Cultures, sorting, etc. I/O: Binary and text streams, files, etc.I/O: Binary and text streams, files, etc. Networking: TCP/IP sockets, HTTP, etc.Networking: TCP/IP sockets, HTTP, etc. Reflection: Metadata and IL emitReflection: Metadata and IL emit Security: Permissions, cryptographySecurity: Permissions, cryptography Text: Encodings, regular expressionsText: Encodings, regular expressions Multithreading and synchronizationMultithreading and synchronization Remoting and serializationRemoting and serialization

Page 25: Microsoft  .NET Framework

Data And XML NamespacesData And XML Namespaces

System.DataSystem.Data

SQLTypesSQLTypes

SQLClientSQLClient

CommonCommon

OleDbOleDb

System.XmlSystem.Xml

SerializationSerialization

XPathXPath

XSLTXSLT

Page 26: Microsoft  .NET Framework

ADO.NET And XMLADO.NET And XML ADO.NET consumes all types of dataADO.NET consumes all types of data

XML (hierarchical), relational, etc.XML (hierarchical), relational, etc. Powerful in-memory data cache (DataSet)Powerful in-memory data cache (DataSet)

DataSet contains various data objects: DataSet contains various data objects: tables, views, relations, constraints, etc.tables, views, relations, constraints, etc.

Lightweight, stateless, disconnectedLightweight, stateless, disconnected Supports both relational and XML accessSupports both relational and XML access

High-performance, low overhead stream High-performance, low overhead stream accessaccess

Great XML support including: Great XML support including: W3C DOM, XSL/T, XPath, and SchemaW3C DOM, XSL/T, XPath, and Schema

Page 27: Microsoft  .NET Framework

VS.NET – DataSet DesignerVS.NET – DataSet Designer

Page 28: Microsoft  .NET Framework

Windows Forms NamespacesWindows Forms Namespaces

System.DrawingSystem.Drawing

Drawing2DDrawing2D

ImagingImaging

PrintingPrinting

TextText

System.Windows.FormsSystem.Windows.Forms

DesignDesign ComponentModelComponentModel

Page 29: Microsoft  .NET Framework

Windows FormsWindows Forms Windows Forms is framework for

building rich GUI applications RAD (Rapid Application Development)

component-based event-driven

Rich set of controls Data aware components Printing support Unicode support UI inheritance

Page 30: Microsoft  .NET Framework

VS.NET – Windows Forms VS.NET – Windows Forms DesignerDesigner

Page 31: Microsoft  .NET Framework

Demo 1Demo 1

Create simple database Create simple database application with:application with:

Windows FormsWindows Forms ADO.NETADO.NET MS SQL ServerMS SQL Server Visual Studio .NETVisual Studio .NET

Page 32: Microsoft  .NET Framework

DataGridDataGrid DataSetDataSet

DatabaseDatabase

Microsoft Microsoft SQL ServerSQL Server

SqlConnectionSqlConnection

SqlDataAdapterSqlDataAdapter

FillFill UpdateUpdate

Demo 1 – ArchitectureDemo 1 – Architecture

ApplicationApplication

Page 33: Microsoft  .NET Framework

ASP.NET NamespacesASP.NET Namespaces

System.WebSystem.Web

CachingCaching

ConfigurationConfiguration

ServicesServices UIUI

SessionStateSessionState

HtmlControlsHtmlControls

WebControlsWebControls

DescriptionDescription

DiscoveryDiscovery

SecuritySecurity

ProtocolsProtocols

Page 34: Microsoft  .NET Framework

Framework for building Web applications Framework for building Web applications and Web services in any .NET languageand Web services in any .NET language

C#, C++, VB.NET, C#, C++, VB.NET, JScriptJScript, etc., etc.

Automatic multiple clients supportAutomatic multiple clients support DHTML, HTML 3.2, WML, small devicesDHTML, HTML 3.2, WML, small devices

Compilation of ASP.NET Web applications Compilation of ASP.NET Web applications into .NET assembliesinto .NET assemblies

Cached the first time when calledCached the first time when called

All subsequent calls use the cached versionAll subsequent calls use the cached version

Separation of code and contentSeparation of code and content Developers and designers can work independentlyDevelopers and designers can work independently

ASP.NETASP.NET

Page 35: Microsoft  .NET Framework

ASP.NETASP.NET

Rich set of ASP.NET server controlsRich set of ASP.NET server controls Data validationData validation Data bound gridsData bound grids

Event-driven execution modelEvent-driven execution model Great Web-services supportGreat Web-services support Easy to deployEasy to deploy High reliability and availabilityHigh reliability and availability High performance and scalabilityHigh performance and scalability Scalable handling of state informationScalable handling of state information

Page 36: Microsoft  .NET Framework

VS.NET – Web Forms DesignerVS.NET – Web Forms Designer

Page 37: Microsoft  .NET Framework

ASP.NET ASP.NET WebMatrixWebMatrix

Page 38: Microsoft  .NET Framework

Demo 2Demo 2

Create simple Web-based Create simple Web-based database application with:database application with:

ASP.NET (Web Forms)ASP.NET (Web Forms) ADO.NETADO.NET MS SQL ServerMS SQL Server MS Internet Information ServerMS Internet Information Server Visual Studio .NETVisual Studio .NET

Page 39: Microsoft  .NET Framework

DataGridDataGrid DataSetDataSet

DatabaseDatabase

Microsoft Microsoft SQL ServerSQL Server

SqlConnectionSqlConnection

SqlDataAdapterSqlDataAdapter

FillFill UpdateUpdate

Demo 2 – ArchitectureDemo 2 – Architecture

Web ApplicationWeb Application

Page 40: Microsoft  .NET Framework

Web ServicesWeb Services Web Services are programmable components Web Services are programmable components

accessible remotely over the Webaccessible remotely over the Web Built on the standards HTTP, XML and SOAPBuilt on the standards HTTP, XML and SOAP Each service is described in WSDLEach service is described in WSDL Easy accessible from any client on any platformEasy accessible from any client on any platform ““Request-response” execution model – like Request-response” execution model – like

component-based programming over the Webcomponent-based programming over the Web

ASP.NET – Simple programming model for ASP.NET – Simple programming model for Web Services developmentWeb Services development Author .ASMX files with normal class methodsAuthor .ASMX files with normal class methods ASP.NET compiles on demand, generates WSDL ASP.NET compiles on demand, generates WSDL

contract, exposes HTML test pagecontract, exposes HTML test page

Page 41: Microsoft  .NET Framework

Web Service Example in C#Web Service Example in C#ParcelTracker.asmxParcelTracker.asmxParcelTracker.asmxParcelTracker.asmx

<%@ WebService Language="C#" %><%@ WebService Language="C#" %>using System;using System;using System.Web.Services;using System.Web.Services;

public class ParcelTrackerWebServicepublic class ParcelTrackerWebService{{ [WebMethod][WebMethod] public string GetOrderStatus(int orderNumber)public string GetOrderStatus(int orderNumber) {{ //// Implementation hereImplementation here }}}}

<%@ WebService Language="C#" %><%@ WebService Language="C#" %>using System;using System;using System.Web.Services;using System.Web.Services;

public class ParcelTrackerWebServicepublic class ParcelTrackerWebService{{ [WebMethod][WebMethod] public string GetOrderStatus(int orderNumber)public string GetOrderStatus(int orderNumber) {{ //// Implementation hereImplementation here }}}}

Page 42: Microsoft  .NET Framework

Demo 3Demo 3

Create simple Web Service Create simple Web Service with:with:

ASP.NET (Web Services)ASP.NET (Web Services) MS Internet Information ServerMS Internet Information Server Visual Studio .NETVisual Studio .NET

Page 43: Microsoft  .NET Framework

Shared Source CLI (Rotor)Shared Source CLI (Rotor)

Non-commercial CLI implementationNon-commercial CLI implementation, , available as source code. Contains:available as source code. Contains: Managed execution environment for MSIL with Managed execution environment for MSIL with

JIT-compilerJIT-compiler Compiler for C# and JscriptCompiler for C# and Jscript Set of development tools – Set of development tools – ilasm, ildasm, ilasm, ildasm,

cordbg, metainfo, …cordbg, metainfo, … Implemented entirely in C++ and C#Implemented entirely in C++ and C# Compiles with MS Visual Studio .NETCompiles with MS Visual Studio .NET Available for research, academic, teaching Available for research, academic, teaching

and other non-profit useand other non-profit use Works on FreeBSDWorks on FreeBSD,, Windows Windows and Mac OSand Mac OS

Page 44: Microsoft  .NET Framework

.NET Framework – Resources.NET Framework – Resources Visit following web sites:Visit following web sites:

..NET Framework Home Site – NET Framework Home Site – http://msdn.microsoft.com/netframework/http://msdn.microsoft.com/netframework/

Microsoft .NET Framework Community – Microsoft .NET Framework Community – http://www.gotdotnet.com/http://www.gotdotnet.com/

ASP.NET – ASP.NET – http://www.asp.net/http://www.asp.net/

.NET Windows Forms – .NET Windows Forms – http://www.windowsforms.net/http://www.windowsforms.net/

O’Reilly .NET Community Site – O’Reilly .NET Community Site – http://www.ondotnet.com/http://www.ondotnet.com/

Microsoft Patterns and Practices – Microsoft Patterns and Practices – http://msdn.microsoft.com/practices/http://msdn.microsoft.com/practices/

Code Project – Code Project – http://www.codeproject.net/http://www.codeproject.net/

Page 45: Microsoft  .NET Framework

.NET Framework – Resources.NET Framework – Resources Visit following web sites:Visit following web sites:

Mono – Open Source .NET Framework – Mono – Open Source .NET Framework – http://www.go-mono.org/http://www.go-mono.org/

Rotor – MS Shared Source .NET CLI – Rotor – MS Shared Source .NET CLI – http://msdn.microsoft.com/net/sscli/http://msdn.microsoft.com/net/sscli/

.NET Framework Course in Sofia .NET Framework Course in Sofia UniversityUniversity – – http://www.nakov.com/dotnet/http://www.nakov.com/dotnet/

Read the news groups:Read the news groups: .NET Framework Official News Group – .NET Framework Official News Group –

news://news://msnews.microsoft.commsnews.microsoft.com//microsoft.public.dotnet.frameworkmicrosoft.public.dotnet.framework

The Bulgarian Developers’ Newsgroup –The Bulgarian Developers’ Newsgroup –news://msnews.microsoft.com/microsoft.public.news://msnews.microsoft.com/microsoft.public.bg.developerbg.developer

Page 46: Microsoft  .NET Framework

Questions?Questions?

Page 47: Microsoft  .NET Framework

My QuestionsMy Questions

How can we create .NET How can we create .NET Framework applications that run Framework applications that run on mobile devices (such as mobile on mobile devices (such as mobile phones, PDA, handhelds, …)?phones, PDA, handhelds, …)?

Answer:Answer: Microsoft .NET Compact FrameworkMicrosoft .NET Compact Framework Standard part of MS Visual Standard part of MS Visual

Studio .NET 2003Studio .NET 2003

Page 48: Microsoft  .NET Framework

My QuestionsMy Questions

How can we precompile .NET How can we precompile .NET assemblies to speedup their assemblies to speedup their execution? Any standard tool?execution? Any standard tool?

Answer:Answer: Use the tool Use the tool ngen.exengen.exe It is standard part of .NET It is standard part of .NET

FrameworkFramework

Page 49: Microsoft  .NET Framework

My QuestionsMy Questions

MSIL is great for decompiling. How MSIL is great for decompiling. How can we protect our .NET code from can we protect our .NET code from reverse engineering attacks? reverse engineering attacks?

Answer:Answer: Use obfuscation tools like Use obfuscation tools like DotfuscatorDotfuscator