44
.Net Framework Joel Pereira Joel Pereira ([email protected]) ([email protected]) Software Design Engineer Software Design Engineer WinFS API Team WinFS API Team Microsoft Corporation Microsoft Corporation

Runtime Environment Of .Net Divya Rathore

Embed Size (px)

Citation preview

Page 1: Runtime Environment Of .Net Divya Rathore

.Net Framework

Joel Pereira ([email protected])Joel Pereira ([email protected])Software Design EngineerSoftware Design EngineerWinFS API TeamWinFS API TeamMicrosoft CorporationMicrosoft Corporation

Page 2: Runtime Environment Of .Net Divya Rathore

Agenda

Part I - FundamentalsPart I - FundamentalsProgramming ModelsProgramming Models

Design Goals and ArchitectureDesign Goals and Architecture

CLR ServicesCLR Services

Part II – Visual Studio 2005Part II – Visual Studio 2005Extending the PlatformExtending the Platform

Improving the PlatformImproving the Platform

Innovation in the PlatformInnovation in the Platform

Page 3: Runtime Environment Of .Net Divya Rathore

Unify Programming Models

Windows APIWindows API

.NET Framework.NET Framework

Consistent API availability regardless ofConsistent API availability regardless oflanguage and programming modellanguage and programming model

ASPASP

Stateless,Stateless,Code embeddedCode embeddedin HTML pagesin HTML pages

MFC/ATLMFC/ATL

Subclassing,Subclassing,Power,Power,

ExpressivenessExpressiveness

VB FormsVB Forms

RAD,RAD,Composition,Composition,

DelegationDelegation

Page 4: Runtime Environment Of .Net Divya Rathore

Make It Simple To Use

OrganizationOrganizationCode organized in hierarchical Code organized in hierarchical namespaces and classesnamespaces and classes

Unified type systemUnified type systemEverything is an object, no variants, one Everything is an object, no variants, one string type, all character data is Unicodestring type, all character data is Unicode

Component OrientedComponent OrientedProperties, methods, events, and attributes Properties, methods, events, and attributes are first class constructsare first class constructs

Design-time functionalityDesign-time functionality

Page 5: Runtime Environment Of .Net Divya Rathore

How Much Simpler?

HWND hwndMain = CreateWindowEx(HWND hwndMain = CreateWindowEx( 0, "MainWClass", "Main Window",0, "MainWClass", "Main Window", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, (HWND)NULL, (HMENU)NULL, hInstance, NULL); (HWND)NULL, (HMENU)NULL, hInstance, NULL); ShowWindow(hwndMain, SW_SHOWDEFAULT); ShowWindow(hwndMain, SW_SHOWDEFAULT); UpdateWindow(hwndMain);UpdateWindow(hwndMain);

Form form = new Form();Form form = new Form();form.Text = "Main Window";form.Text = "Main Window";form.Show();form.Show();

Windows APIWindows API

.NET Framework.NET Framework

Page 6: Runtime Environment Of .Net Divya Rathore

Hello World Demo

What you needWhat you need

Page 7: Runtime Environment Of .Net Divya Rathore

Agenda

Part I - FundamentalsPart I - FundamentalsProgramming ModelsProgramming Models

Design Goals and ArchitectureDesign Goals and Architecture

CLR ServicesCLR Services

Part II – Visual Studio 2005Part II – Visual Studio 2005Extending the PlatformExtending the Platform

Improving the PlatformImproving the Platform

Innovation in the PlatformInnovation in the Platform

Page 8: Runtime Environment Of .Net Divya Rathore

Common Language RuntimeDesign Goals

Dramatically simplifies development Dramatically simplifies development and deploymentand deployment

Unifies programming modelsUnifies programming models

Provides robust and secure execution Provides robust and secure execution environmentenvironment

Supports multiple programming Supports multiple programming languageslanguages

Page 9: Runtime Environment Of .Net Divya Rathore

Architectural Overview

Co

mm

on

Lan

gu

age

Ru

nti

me

Co

mm

on

Lan

gu

age

Ru

nti

me

FrameworkFramework

Class loader and layoutClass loader and layout

GC, stack walk, code managerGC, stack walk, code manager

IL t

o

IL t

o

nat

ive

cod

e n

ativ

e co

de

com

pile

rsco

mp

ilers

Sec

uri

tyS

ecu

rity

Exe

cuti

on

Exe

cuti

on

Su

pp

ort

Su

pp

ort

Base ClassesBase Classes

Page 10: Runtime Environment Of .Net Divya Rathore

AssemblyAssembly

Compilation And Execution

Source Source CodeCode

Language Language CompilerCompiler

CompilationCompilation

At installation or the At installation or the first time each first time each

method is calledmethod is calledExecutionExecution

JIT JIT CompilerCompiler

NativeNative

CodeCode

Code (IL)Code (IL)

MetadataMetadata

Page 11: Runtime Environment Of .Net Divya Rathore

Languages

The CLR is Language NeutralThe CLR is Language NeutralAll languages are first class playersAll languages are first class players

You can leverage your existing skillsYou can leverage your existing skills

Common Language SpecificationCommon Language SpecificationSet of features guaranteed to be in all Set of features guaranteed to be in all languageslanguages

We are providingWe are providingVB, C++, C#, J#, JScriptVB, C++, C#, J#, JScript

Third-parties are buildingThird-parties are buildingAPL, COBOL, Pascal, Eiffel, Haskell, ML, APL, COBOL, Pascal, Eiffel, Haskell, ML, Oberon, Perl, Python, Scheme, Smalltalk…Oberon, Perl, Python, Scheme, Smalltalk…

Page 12: Runtime Environment Of .Net Divya Rathore

Hello World Demo

What you needWhat you need

MSILMSIL

Page 13: Runtime Environment Of .Net Divya Rathore

Agenda

Part I - FundamentalsPart I - FundamentalsProgramming ModelsProgramming Models

Design Goals and ArchitectureDesign Goals and Architecture

CLR ServicesCLR Services

Part II – Visual Studio 2005Part II – Visual Studio 2005Extending the PlatformExtending the Platform

Improving the PlatformImproving the Platform

Innovation in the PlatformInnovation in the Platform

Page 14: Runtime Environment Of .Net Divya Rathore

Component-Based Programming

3 core technologies make building and 3 core technologies make building and using components easyusing components easy

Type safetyType safety

Automatic memory managementAutomatic memory management

MetadataMetadata

This greatly simplifies application This greatly simplifies application developmentdevelopment

Page 15: Runtime Environment Of .Net Divya Rathore

Type Safety

Type safety ensures that objects are used Type safety ensures that objects are used the way they were intended to be usedthe way they were intended to be used

Prevents an object’s state from being corruptedPrevents an object’s state from being corrupted

The CLR enforces type safetyThe CLR enforces type safetyAttempting to coerce an object to an Attempting to coerce an object to an incompatible type causes the CLR to throw an incompatible type causes the CLR to throw an exceptionexception

Type safety means code confidenceType safety means code confidenceCommon programmer errors will be found Common programmer errors will be found immediatelyimmediatelyRectangle(hwnd, 0, 0, 10, 10);Rectangle(hwnd, 0, 0, 10, 10);

//hwnd should be an hdc//hwnd should be an hdc

MessageBox(hwnd, “”, “”, IDOK);MessageBox(hwnd, “”, “”, IDOK);

//IDOK should be MB_OK//IDOK should be MB_OK

Page 16: Runtime Environment Of .Net Divya Rathore

Automatic Memory Management

The CLR tracks the code’s use of objects and The CLR tracks the code’s use of objects and ensuresensures

Objects are not freed while still in use (no memory Objects are not freed while still in use (no memory corruption)corruption)

Objects are freed when no longer in use (no memory leaks)Objects are freed when no longer in use (no memory leaks)

Code is easier to write because there is no question Code is easier to write because there is no question as to which component is responsible to free an as to which component is responsible to free an objectobject

When passed a buffer, who frees it: caller or callee?When passed a buffer, who frees it: caller or callee?

Each process has 1 heap used by all componentsEach process has 1 heap used by all componentsObjects can’t be allocated from different heapsObjects can’t be allocated from different heaps

You don’t have to know which heap memory was allocated You don’t have to know which heap memory was allocated in or which API to call to free the memoryin or which API to call to free the memory

In fact, there is no API to free memory, the GC does itIn fact, there is no API to free memory, the GC does it

Page 17: Runtime Environment Of .Net Divya Rathore

Metadata

Set of data tables embedded in an EXE/DLLSet of data tables embedded in an EXE/DLLThe tables describe what is defined in the file (Type, fields, The tables describe what is defined in the file (Type, fields, methods, etc.)methods, etc.)

Every component’s interface is described by metadata tablesEvery component’s interface is described by metadata tablesA component’s implementation is described by Intermediate A component’s implementation is described by Intermediate LanguageLanguage

The existence of metadata tables enables many featuresThe existence of metadata tables enables many featuresNo header filesNo header files

Visual Studio’s IntelliSenseVisual Studio’s IntelliSense

Components don’t have to be registered in the registryComponents don’t have to be registered in the registry

Components don’t need separate IDL or TLB filesComponents don’t need separate IDL or TLB files

The GC knows when an object’s fields refer to other objectsThe GC knows when an object’s fields refer to other objects

An object’s fields can be automatically serialized/deserializedAn object’s fields can be automatically serialized/deserialized

At runtime, an application can determine what types are in a file At runtime, an application can determine what types are in a file and what members the type defines (also known as late binding)and what members the type defines (also known as late binding)

Components can be written/used by different languagesComponents can be written/used by different languages

Page 18: Runtime Environment Of .Net Divya Rathore

Metadata: Creation And Use

MetadataMetadata(and code)(and code)

DebuggerDebugger

Schema Schema GeneratorGenerator

ProfilerProfiler

CompilersCompilers

Proxy GeneratorProxy Generator

Type BrowserType Browser

CompilerCompiler

SourceSourceCodeCode

XML encodingXML encoding(SDL or SUDS)(SDL or SUDS)

SerializationSerialization

DesignersDesigners

ReflectionReflection

TLB ExporterTLB Exporter

Page 19: Runtime Environment Of .Net Divya Rathore

Runtime Execution Model

ClassClassLoaderLoader

CPUCPU

ManagedManagedNative CodeNative Code

AssemblyAssembly

First callFirst callto methodto method

First reference First reference to to typetype

AssemblyAssemblyResolverResolver

First reference First reference to Assemblyto Assembly

IL to nativeIL to nativeconversionconversion

Page 20: Runtime Environment Of .Net Divya Rathore

JIT Compiler - Inline

Page 21: Runtime Environment Of .Net Divya Rathore

Standardization

A subset of the .NET Framework and C# A subset of the .NET Framework and C# submitted to ECMAsubmitted to ECMA

ECMA and ISO International StandardsECMA and ISO International Standards

Co-sponsored with Intel, Hewlett-PackardCo-sponsored with Intel, Hewlett-Packard

Common Language InfrastructureCommon Language InfrastructureBased on Common Language Runtime and Based on Common Language Runtime and Base FrameworkBase Framework

Layered into increasing levels of Layered into increasing levels of functionalityfunctionality

Page 22: Runtime Environment Of .Net Divya Rathore

Rotor (SSCLI)

Shared-Source version of the Shared-Source version of the CLR+BCL+C# compilerCLR+BCL+C# compiler

Ports available: Windows, FreeBSD, Ports available: Windows, FreeBSD, OSX, etcOSX, etc

Real product code offers real world Real product code offers real world learning learning

http://sscli.orghttp://sscli.org

Page 23: Runtime Environment Of .Net Divya Rathore

Developer Roadmap

• “ “Orcas” releaseOrcas” release

• Windows “Longhorn” Windows “Longhorn” integrationintegration

• New UI tools and New UI tools and designers designers

• Extensive managed Extensive managed interfacesinterfaces

Visual Studio Visual Studio Orcas Orcas

“Longhorn”“Longhorn”

Visual StudioVisual Studio.NET 2003.NET 2003

• “ “Everett Release”Everett Release”

• Windows Server 2003 Windows Server 2003 integrationintegration

• Support for .NET Support for .NET Compact Framework Compact Framework and device and device development development

• Improved performanceImproved performance

Visual Studio 2005 Visual Studio 2005 “Yukon”“Yukon”

• “ “Whidbey” releaseWhidbey” release

• SQL Server SQL Server integrationintegration

• Improved IDE Improved IDE productivity and productivity and community supportcommunity support

• Extended support for Extended support for XML Web servicesXML Web services

• Office Office programmabilityprogrammability

Page 24: Runtime Environment Of .Net Divya Rathore

Agenda

Part I - FundamentalsPart I - FundamentalsDesign Goals Design Goals

ArchitectureArchitecture

CLR ServicesCLR Services

Part II – Visual Studio 2005Part II – Visual Studio 2005Extending the PlatformExtending the Platform

Improving the PlatformImproving the Platform

Innovation in the PlatformInnovation in the Platform

Page 25: Runtime Environment Of .Net Divya Rathore

SQL Server IntegrationDesign Goal

Bring framework programming model Bring framework programming model into the database tierinto the database tier

Allow business logic to easily migrate Allow business logic to easily migrate to the most appropriate tierto the most appropriate tier

Enable Enable safe safe database extensionsdatabase extensions

Result: Stored Procedures, Triggers, Result: Stored Procedures, Triggers, data types defined in managed codedata types defined in managed code

Page 26: Runtime Environment Of .Net Divya Rathore

VS .NET VS .NET ProjectProject

Assembly: geom.dll

VB, C#, …VB, C#, … BuildBuild

SQL ServerSQL Server

SQL Data Definition: SQL Data Definition: create create assembly … assembly … create function … create function … create create procedure … procedure … create trigger … create trigger … create create type …type …SQL Queries: SQL Queries:

SELECT name FROM Supplier SELECT name FROM Supplier WHERE Location.Distance ( @point ) < 3WHERE Location.Distance ( @point ) < 3

CLR hosted by SQL (in-proc)

SQL CLR Functionality

Define Location.Distance()

Page 27: Runtime Environment Of .Net Divya Rathore

Sql Programming Model Splitting a string

The old way…. The old way…. declare @str varchar(200)declare @str varchar(200)select @Str = 'Microsoft Corporation|SQL Server|2003|select @Str = 'Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-08-20|11:32:00|Document|3.b.3'SQL-CLR|2002-08-20|11:32:00|Document|3.b.3'SELECTSELECTsubstring(@Str + '|', 0 + 1, substring(@Str + '|', 0 + 1, charindex('|', @Str + '|', 0 + 1) - 0 - 1 ),charindex('|', @Str + '|', 0 + 1) - 0 - 1 ),substring(@Str + '|', charindex('|', @Str + '|') + 1, substring(@Str + '|', charindex('|', @Str + '|') + 1, charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - charindex('|', @Str + '|') + 1) - charindex('|', @Str + '|') - 1 ),charindex('|', @Str + '|') - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1,charindex('|', @Str + '|') + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|') + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - 1 ),charindex('|', @Str + '|') + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1, charindex('|', @Str + '|') + 1) + 1) + 1, charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|') + 1) + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|') + 1) + 1) - 1 ),charindex('|', @Str + '|') + 1) + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1,charindex('|', @Str + '|') + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|', '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) - 1 ),charindex('|', @Str + '|') + 1) + 1) + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|', '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1,charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|', '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|', '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - 1 ),charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|', '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1, 1, charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|', '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - 1) - charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|', '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - 1 ),1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1,1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|', charindex('|', @Str + charindex('|', @Str + '|', charindex('|', @Str + '|','|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1) - 1) + 1) - charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - 1 ) 1) - 1 )

declare @str varchar(200)declare @str varchar(200)select @Str = 'Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-select @Str = 'Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-08-20|11:32:00|Document|3.b.3'08-20|11:32:00|Document|3.b.3'SELECTSELECTsubstring(@Str + '|', 0 + 1, substring(@Str + '|', 0 + 1, charindex('|', @Str + '|', 0 + 1) - 0 - 1 ),charindex('|', @Str + '|', 0 + 1) - 0 - 1 ),substring(@Str + '|', charindex('|', @Str + '|') + 1, substring(@Str + '|', charindex('|', @Str + '|') + 1, charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - charindex('|', @Str + '|') + 1) - charindex('|', @Str + '|') - 1 ),charindex('|', @Str + '|') - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1,charindex('|', @Str + '|') + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - 1 ),charindex('|', @Str + '|') + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1, charindex('|', @Str + '|') + 1) + 1) + 1, charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) - 1 ),charindex('|', @Str + '|') + 1) + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1,charindex('|', @Str + '|') + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) - 1 ),charindex('|', @Str + '|') + 1) + 1) + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1,charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) -charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - 1 ),charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - 1 ),charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - 1 ),substring(@Str + '|', charindex('|', @Str + '|', substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1,charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|',charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - 1 ) charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - 1 )

Page 28: Runtime Environment Of .Net Divya Rathore

Sql Programming Model Splitting a string

Public Shared Sub SplitString()Public Shared Sub SplitString() Dim s As StringDim s As String s = "Microsoft Corporation|SQL s = "Microsoft Corporation|SQL Server|Server|2003|SQL-CLR|2002-08-2003|SQL-CLR|2002-08- 20|11:32:00|20|11:32:00|Document|3.b.3"Document|3.b.3" Dim myArray() As String = Split(s, "|")Dim myArray() As String = Split(s, "|")End SubEnd Sub

The new way….

Page 29: Runtime Environment Of .Net Divya Rathore

Moving to 64 bit64 bit for Servers and workstations64 bit for Servers and workstations

X64 and IA64 bit supportX64 and IA64 bit support

Enable Yukon and ASP.NETEnable Yukon and ASP.NET

Verifiable managed binaries just run!Verifiable managed binaries just run!

VS: Runs as a 32bit applicationVS: Runs as a 32bit applicationYou can develop, deploy, and debug 32 You can develop, deploy, and debug 32 and 64bit applicationsand 64bit applications

Page 30: Runtime Environment Of .Net Divya Rathore

Agenda

Part I - FundamentalsPart I - FundamentalsDesign Goals Design Goals

ArchitectureArchitecture

CLR ServicesCLR Services

Part II – Visual Studio 2005Part II – Visual Studio 2005Extending the PlatformExtending the Platform

Improving the PlatformImproving the Platform

Innovation in the PlatformInnovation in the Platform

Page 31: Runtime Environment Of .Net Divya Rathore

PerformanceObjectives: make .NET an even greater programming Objectives: make .NET an even greater programming

platformplatformLong-Term: make the performance characteristics of Long-Term: make the performance characteristics of the CLR similar to native codethe CLR similar to native code

Reduce marginal cost of additional managed processesReduce marginal cost of additional managed processes

Reduce startup time and working setReduce startup time and working set

NGenNGenCompiles IL code to native code, saving results to diskCompiles IL code to native code, saving results to disk

Advantages: no need to recompile IL to native code, Advantages: no need to recompile IL to native code, and class layout already set so better startup timeand class layout already set so better startup time

Whidbey: Significant reductions in the amount of Whidbey: Significant reductions in the amount of private, non-shareable working setprivate, non-shareable working set

OS: ‘no-Jit’ plan, all managed code will be NGenedOS: ‘no-Jit’ plan, all managed code will be NGened

Page 32: Runtime Environment Of .Net Divya Rathore

Performance everywhereNew, Performant APIsNew, Performant APIs

APIs for faster resource lookupAPIs for faster resource lookup

Lightweight CodeGen: only generates Lightweight CodeGen: only generates essential code (contrast to Reflect Emit)essential code (contrast to Reflect Emit)

Existing APIs ImprovedExisting APIs Improved

Cross AppDomain RemotingCross AppDomain RemotingBetween 1.1 and 200x faster. Biggest gains for simpler items Between 1.1 and 200x faster. Biggest gains for simpler items (strings, integers, serializable objects)(strings, integers, serializable objects)

Delegate invoke performance has more than Delegate invoke performance has more than doubleddoubled

AppDomain Footprints: significantly reducedAppDomain Footprints: significantly reduced

UTF8Encoding: translation is 2.5x fasterUTF8Encoding: translation is 2.5x faster

Page 33: Runtime Environment Of .Net Divya Rathore

TryParseTryParse

Page 34: Runtime Environment Of .Net Divya Rathore

RAD Debugging

Edit and Continue: Edit Code at runtimeEdit and Continue: Edit Code at runtimeAllowed Edits: ExamplesAllowed Edits: Examples

Add private fields to a classAdd private fields to a class

Add private non-virtual methods to a classAdd private non-virtual methods to a class

Change a function body, even while steppingChange a function body, even while stepping

Disallowed Edits: ExamplesDisallowed Edits: Examples

Removing fields/methodsRemoving fields/methods

Edits to generic classesEdits to generic classes

Serialization will not recognize new fieldsSerialization will not recognize new fields

Display Attributes for a better debugging Display Attributes for a better debugging experienceexperience

Page 35: Runtime Environment Of .Net Divya Rathore

CLR Security

New cryptography supportNew cryptography supportPKI and PKCS7 supportPKI and PKCS7 support

XML encryption supportXML encryption support

Enhanced support for X509 certificatesEnhanced support for X509 certificates

Enhanced Application SecurityEnhanced Application SecurityPermission CalculatorPermission Calculator

Integration with ClickOnceIntegration with ClickOnce

Better SecurityExceptionBetter SecurityException

Debug-In-ZoneDebug-In-Zone

Managed ACL SupportManaged ACL Support

Page 36: Runtime Environment Of .Net Divya Rathore

Agenda

Part I - FundamentalsPart I - FundamentalsDesign Goals Design Goals

ArchitectureArchitecture

CLR ServicesCLR Services

Part II – Visual Studio 2005Part II – Visual Studio 2005Extending the PlatformExtending the Platform

Improving the PlatformImproving the Platform

Innovation in the PlatformInnovation in the Platform

Page 37: Runtime Environment Of .Net Divya Rathore

GenericsWhy generics?Why generics?

Compile-time type checkingCompile-time type checking

Performance (no boxing, no downcasts)Performance (no boxing, no downcasts)

Reduced code bloat (typed collections)Reduced code bloat (typed collections)

VB, C#, MC++ produce & consume genericsVB, C#, MC++ produce & consume generics

UseUse generics freely in internal APIsgenerics freely in internal APIs

Consider using generics in public APIsConsider using generics in public APIsGenerics are not yet in CLSGenerics are not yet in CLS

To be CLS compliant, provide a non-generic API To be CLS compliant, provide a non-generic API alternativealternative

Microsoft is actively pursuing standardization of Microsoft is actively pursuing standardization of generics in runtime and languagesgenerics in runtime and languages

Page 38: Runtime Environment Of .Net Divya Rathore

Enhancing The Base LibraryOther Generics to look out for

Nullable(Nullable(Of TOf T))Extremely useful for situations where null is Extremely useful for situations where null is a value, such as database valuetypesa value, such as database valuetypes

EventHandlerEventHandler<T><T>Saves on making your own EventHandlersSaves on making your own EventHandlers

Dim intVal as Nullable(Dim intVal as Nullable(Of IntegerOf Integer) = 5) = 5IfIf intVal.HasValue intVal.HasValue ThenThen ‘ checks for a value ‘ checks for a value

delegate voiddelegate void EventHandlerEventHandler<T><T>((ObjectObject sender, sender, TT e) e) wherewhere T : T : EventArgsEventArgs;;

Page 39: Runtime Environment Of .Net Divya Rathore

Whidbey Tracing FeaturesPluggable FormattersPluggable Formatters

Pre-WhidbeyPre-Whidbey : Formatting of Trace : Formatting of Trace information was predefined, and not information was predefined, and not controllablecontrollable

WhidbeyWhidbey : Predefined formatters : Predefined formatters (delimiter, xml) added, and you can (delimiter, xml) added, and you can make your ownmake your own

MySource;Error;13;Wrong key;;;;;;318361290184;MySource;Error;13;Wrong key;;;;;;318361290184;

Additional ListenersAdditional Listeners

Pre-WhidbeyPre-Whidbey : No Console listener, : No Console listener, ASP had their own tracing mechanismASP had their own tracing mechanism

WhidbeyWhidbey : Added Console listener. : Added Console listener. Integrated ASP tracing into our own, Integrated ASP tracing into our own, and added ETW listenerand added ETW listener

Page 40: Runtime Environment Of .Net Divya Rathore

Whidbey Tracing FeaturesAuto-generated DataAuto-generated Data

Pre-WhidbeyPre-Whidbey : Standard information such as : Standard information such as timestamp or callstack would have to be timestamp or callstack would have to be explicitly generatedexplicitly generatedWhidbeyWhidbey : An Admin can easily generate this : An Admin can easily generate this data automatically, via config settingsdata automatically, via config settings<<listenerslisteners>>

<<addadd namename="examplelog" ="examplelog" typetype= …= …

Simple Thread IdentificationSimple Thread IdentificationPre-WhidbeyPre-Whidbey : specific threads were difficult : specific threads were difficult to identify, and filter onto identify, and filter onWhidbeyWhidbey : Correlation ID has been added, : Correlation ID has been added, which allows quick and easy identification of which allows quick and easy identification of a thread, and simple subsequent filteringa thread, and simple subsequent filtering

Page 41: Runtime Environment Of .Net Divya Rathore

Whidbey Tracing Features

Listener FilteringListener FilteringPre-WhidbeyPre-Whidbey : Formatting of Trace : Formatting of Trace information was predefined, and not information was predefined, and not controllablecontrollableWhidbey Whidbey : Assign filtering to : Assign filtering to listeners, so only certain messages listeners, so only certain messages are traced. This allows filtering on are traced. This allows filtering on any property of a message. E.g., ID, any property of a message. E.g., ID, TimeStamp, etc.TimeStamp, etc.

SwitchesSwitchesPre-WhidbeyPre-Whidbey : Couldn’t determine : Couldn’t determine what tracing a component supportedwhat tracing a component supportedWhidbeyWhidbey : Support the ability to : Support the ability to determine what tracing mechanisms determine what tracing mechanisms a component hasa component has

Page 42: Runtime Environment Of .Net Divya Rathore

Attend a free chat or web casthttp://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asp

List of newsgroupshttp://communities2.microsoft.com/communities/newsgroups/en-us/default.aspx

MS Community Siteshttp://www.microsoft.com/communities/default.mspx

Local User Groupshttp://www.msdnbrasil.com.br

Community siteshttp://www.microsoft.com/communities/related/default.mspx

Page 43: Runtime Environment Of .Net Divya Rathore

Resources

BCL BlogBCL Bloghttp://weblogs.asp.net/bclteamhttp://weblogs.asp.net/bclteam

BCL WebsiteBCL Websitehttp://www.gotdotnet.com/team/clr/bcl/default.aspxhttp://www.gotdotnet.com/team/clr/bcl/default.aspx

BCL public mail aliasBCL public mail [email protected]@microsoft.com

ReferenceReference.NET Framework Standard Library Annotated Reference.NET Framework Standard Library Annotated Reference

Applied Microsoft .Net Framework ProgrammingApplied Microsoft .Net Framework Programming

Page 44: Runtime Environment Of .Net Divya Rathore

Q & A:

DIVYA

RATHORE