joel net
Shared by: XZX8QW
-
Stats
- views:
- 1
- posted:
- 11/10/2011
- language:
- English
- pages:
- 45
Document Sample


.Net Framework
Joel Pereira (joelcdp@microsoft.com)
Software Design Engineer
WinFS API Team
Microsoft Corporation
Agenda
Part I - Fundamentals
Programming Models
Design Goals and Architecture
CLR Services
Part II – Visual Studio 2005
Extending the Platform
Improving the Platform
Innovation in the Platform
Unify Programming Models
Consistent API availability regardless of
language and programming model
.NET Framework
RAD, Subclassing, Stateless,
Composition, Power, Code embedded
Delegation Expressiveness in HTML pages
VB Forms MFC/ATL ASP
Windows API
Make It Simple To Use
Organization
Code organized in hierarchical
namespaces and classes
Unified type system
Everything is an object, no variants, one
string type, all character data is Unicode
Component Oriented
Properties, methods, events, and attributes
are first class constructs
Design-time functionality
How Much Simpler?
Windows API
HWND hwndMain = CreateWindowEx(
0, "MainWClass", "Main Window",
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
(HWND)NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hwndMain, SW_SHOWDEFAULT);
UpdateWindow(hwndMain);
.NET Framework
Form form = new Form();
form.Text = "Main Window";
form.Show();
Hello World Demo
What you need
Agenda
Part I - Fundamentals
Programming Models
Design Goals and Architecture
CLR Services
Part II – Visual Studio 2005
Extending the Platform
Improving the Platform
Innovation in the Platform
Common Language Runtime
Design Goals
Dramatically simplifies development
and deployment
Unifies programming models
Provides robust and secure execution
environment
Supports multiple programming
languages
Architectural Overview
Framework
Base Classes
Common Language Runtime
Execution
native code
Security
compilers
Support
IL to
GC, stack walk, code manager
Class loader and layout
Compilation And Execution
Compilation
Source Language Code (IL)
Assembly
Code Compiler Metadata
Native JIT
Code Compiler At installation or the
first time each
Execution method is called
Languages
The CLR is Language Neutral
All languages are first class players
You can leverage your existing skills
Common Language Specification
Set of features guaranteed to be in all
languages
We are providing
VB, C++, C#, J#, JScript
Third-parties are building
APL, COBOL, Pascal, Eiffel, Haskell, ML,
Oberon, Perl, Python, Scheme, Smalltalk…
Hello World Demo
What you need
MSIL
Agenda
Part I - Fundamentals
Programming Models
Design Goals and Architecture
CLR Services
Part II – Visual Studio 2005
Extending the Platform
Improving the Platform
Innovation in the Platform
Component-Based Programming
3 core technologies make building and
using components easy
Type safety
Automatic memory management
Metadata
This greatly simplifies application
development
Type Safety
Type safety ensures that objects are used
the way they were intended to be used
Prevents an object’s state from being corrupted
The CLR enforces type safety
Attempting to coerce an object to an
incompatible type causes the CLR to throw an
exception
Type safety means code confidence
Common programmer errors will be found
immediately
Rectangle(hwnd, 0, 0, 10, 10);
//hwnd should be an hdc
MessageBox(hwnd, “”, “”, IDOK);
//IDOK should be MB_OK
Automatic Memory Management
The CLR tracks the code’s use of objects and
ensures
Objects are not freed while still in use (no memory
corruption)
Objects are freed when no longer in use (no memory leaks)
Code is easier to write because there is no question
as to which component is responsible to free an
object
When passed a buffer, who frees it: caller or callee?
Each process has 1 heap used by all components
Objects can’t be allocated from different heaps
You don’t have to know which heap memory was allocated
in or which API to call to free the memory
In fact, there is no API to free memory, the GC does it
Metadata
Set of data tables embedded in an EXE/DLL
The tables describe what is defined in the file (Type, fields,
methods, etc.)
Every component’s interface is described by metadata tables
A component’s implementation is described by Intermediate
Language
The existence of metadata tables enables many features
No header files
Visual Studio’s IntelliSense
Components don’t have to be registered in the registry
Components don’t need separate IDL or TLB files
The GC knows when an object’s fields refer to other objects
An object’s fields can be automatically serialized/deserialized
At runtime, an application can determine what types are in a file
and what members the type defines (also known as late binding)
Components can be written/used by different languages
Metadata: Creation And Use
Serialization Source Reflection
Code
TLB Exporter Designers
Compiler
Compilers Debugger
Type Browser Metadata Profiler
(and code)
Schema Proxy Generator
Generator
XML encoding
(SDL or SUDS)
Runtime Execution Model
Class
Assembly First reference
Loader
to type
IL to native
Assembly conversion
Resolver
First reference
to Assembly Managed First call
Native Code to method
CPU
JIT Compiler - Inline
Standardization
A subset of the .NET Framework and C#
submitted to ECMA
ECMA and ISO International Standards
Co-sponsored with Intel, Hewlett-Packard
Common Language Infrastructure
Based on Common Language Runtime and
Base Framework
Layered into increasing levels of
functionality
Rotor (SSCLI)
Shared-Source version of the
CLR+BCL+C# compiler
Ports available: Windows, FreeBSD,
OSX, etc
Real product code offers real world
learning
http://sscli.org
Developer Roadmap
Visual Studio Orcas
“Longhorn”
Visual Studio 2005
• “Orcas” release
“Yukon”
•Windows “Longhorn”
Visual Studio • “Whidbey” release integration
.NET 2003 •SQL Server integration •New UI tools and
• “Everett Release” •Improved IDE productivity designers
•Windows Server 2003 and community support •Extensive managed
integration •Extended support for interfaces
•Support for .NET Compact XML Web services
Framework and device •Office programmability
development
•Improved performance
Agenda
Part I - Fundamentals
Design Goals
Architecture
CLR Services
Part II – Visual Studio 2005
Extending the Platform
Improving the Platform
Innovation in the Platform
SQL Server Integration
Design Goal
Bring framework programming model
into the database tier
Allow business logic to easily migrate
to the most appropriate tier
Enable safe database extensions
Result: Stored Procedures, Triggers,
data types defined in managed code
SQL CLR Functionality
VB, C#, … Build
VS .NET
Assembly:
Project geom.dll
Define Location.Distance()
SQL Data Definition:
create assembly …
create function …
CLR hosted by create procedure …
SQL (in-proc) create trigger …
create type …
SQL Server
SQL Queries:
SELECT name FROM Supplier
WHERE Location.Distance ( @point ) < 3
Sql Programming Model
Splitting a string
The old way….
declare @str varchar(200) declare @str varchar(200)
select @Str = 'Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-
08-20|11:32:00|Document|3.b.3'
select @Str = 'Microsoft Corporation|SQLSELECT
substring(@Str + '|', 0 + 1,
charindex('|', @Str + '|', 0 + 1) - 0 - 1 ),
substring(@Str + '|', charindex('|', @Str + '|') + 1,
Server|2003|SQL-CLR|2002-08-20|11:32:00|Document|3.b.3'
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) -
charindex('|', @Str + '|') - 1 ),
substring(@Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1,
SELECT charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) -
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) - 1 ),
substring(@Str + '|', 0 + 1,
substring(@Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1,
charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|', 0 + 1) - 0 - 1 ),
charindex('|', @Str + '|') + 1) + 1) + 1) -
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) - 1 ),
substring(@Str + '|', charindex('|', @Str + '|',
substring(@Str + '|', charindex('|', @Str + '|') + 1,
charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1) + 1,
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1) + 1) -
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) -
charindex('|', @Str + '|') + 1) + 1) + 1) - 1 ),
substring(@Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1,
charindex('|', @Str + '|') - 1 ), charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) -
substring(@Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - 1 ),
substring(@Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1, charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
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 + '|') + 1) + 1) + 1) + 1) + 1) + 1) -
'|', charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) -
charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - 1 ),
substring(@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 + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) - 1 ),
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1) -
charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
substring(@Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|',
charindex('|', @Str + '|', charindex('|', @Str + '|',
charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - 1 )
Sql Programming Model
Splitting a string
The new way….
Public Shared Sub SplitString()
Dim s As String
s = "Microsoft Corporation|SQL
Server|2003|SQL-CLR|2002-08-
20|11:32:00|Document|3.b.3"
Dim myArray() As String = Split(s, "|")
End Sub
Moving to 64 bit
64 bit for Servers and workstations
X64 and IA64 bit support
Enable Yukon and ASP.NET
Verifiable managed binaries just run!
VS: Runs as a 32bit application
You can develop, deploy, and debug 32
and 64bit applications
Agenda
Part I - Fundamentals
Design Goals
Architecture
CLR Services
Part II – Visual Studio 2005
Extending the Platform
Improving the Platform
Innovation in the Platform
Performance
Objectives: make .NET an even greater programming
platform
Long-Term: make the performance characteristics of
the CLR similar to native code
Reduce marginal cost of additional managed processes
Reduce startup time and working set
NGen
Compiles IL code to native code, saving results to disk
Advantages: no need to recompile IL to native code,
and class layout already set so better startup time
Whidbey: Significant reductions in the amount of
private, non-shareable working set
OS: ‘no-Jit’ plan, all managed code will be NGened
Performance everywhere
New, Performant APIs
APIs for faster resource lookup
Lightweight CodeGen: only generates
essential code (contrast to Reflect Emit)
Existing APIs Improved
Cross AppDomain Remoting
Between 1.1 and 200x faster. Biggest gains for simpler items
(strings, integers, serializable objects)
Delegate invoke performance has more than
doubled
AppDomain Footprints: significantly reduced
UTF8Encoding: translation is 2.5x faster
TryParse
RAD Debugging
Edit and Continue: Edit Code at runtime
Allowed Edits: Examples
Add private fields to a class
Add private non-virtual methods to a class
Change a function body, even while stepping
Disallowed Edits: Examples
Removing fields/methods
Edits to generic classes
Serialization will not recognize new fields
Display Attributes for a better debugging
experience
CLR Security
New cryptography support
PKI and PKCS7 support
XML encryption support
Enhanced support for X509 certificates
Enhanced Application Security
Permission Calculator
Integration with ClickOnce
Better SecurityException
Debug-In-Zone
Managed ACL Support
Agenda
Part I - Fundamentals
Design Goals
Architecture
CLR Services
Part II – Visual Studio 2005
Extending the Platform
Improving the Platform
Innovation in the Platform
Generics
Why generics?
Compile-time type checking
Performance (no boxing, no downcasts)
Reduced code bloat (typed collections)
VB, C#, MC++ produce & consume generics
Use generics freely in internal APIs
Consider using generics in public APIs
Generics are not yet in CLS
To be CLS compliant, provide a non-generic API
alternative
Microsoft is actively pursuing standardization of
generics in runtime and languages
Enhancing The Base Library
Other Generics to look out for
Nullable(Of T)
Extremely useful for situations where null is
a value, such as database valuetypes
Dim intVal as Nullable(Of Integer) = 5
If intVal.HasValue Then ‘ checks for a value
EventHandler<T>
Saves on making your own EventHandlers
delegate void EventHandler<T>(Object sender, T e)
where T : EventArgs;
Whidbey Tracing Features
Pluggable Formatters
Pre-Whidbey : Formatting of Trace
information was predefined, and not
controllable
Whidbey : Predefined formatters (delimiter,
xml) added, and you can make your own
MySource;Error;13;Wrong key;;;;;;318361290184;
Additional Listeners
Pre-Whidbey : No Console listener, ASP had
their own tracing mechanism
Whidbey : Added Console listener. Integrated
ASP tracing into our own, and added ETW
listener
Whidbey Tracing Features
Auto-generated Data
Pre-Whidbey : Standard information such as
timestamp or callstack would have to be explicitly
generated
Whidbey : An Admin can easily generate this data
automatically, via config settings
<listeners>
<add name="examplelog" type= …
Simple Thread Identification
Pre-Whidbey : specific threads were difficult to
identify, and filter on
Whidbey : Correlation ID has been added, which
allows quick and easy identification of a thread, and
simple subsequent filtering
Whidbey Tracing Features
Listener Filtering
Pre-Whidbey : Formatting of Trace
information was predefined, and not
controllable
Whidbey : Assign filtering to listeners, so
only certain messages are traced. This
allows filtering on any property of a
message. E.g., ID, TimeStamp, etc.
Switches
Pre-Whidbey : Couldn’t determine what
tracing a component supported
Whidbey : Support the ability to determine
what tracing mechanisms a component has
Attend a free chat or web cast
http://www.microsoft.com/communities/chats/default.mspx
http://www.microsoft.com/usa/webcasts/default.asp
List of newsgroups
http://communities2.microsoft.com/
communities/newsgroups/en-us/default.aspx
MS Community Sites
http://www.microsoft.com/communities/default.mspx
Local User Groups
http://www.msdnbrasil.com.br
Community sites
http://www.microsoft.com/communities/related/default.mspx
Resources
BCL Blog
http://weblogs.asp.net/bclteam
BCL Website
http://www.gotdotnet.com/team/clr/bcl/default.aspx
BCL public mail alias
bclpub@microsoft.com
Reference
.NET Framework Standard Library Annotated Reference
Applied Microsoft .Net Framework Programming
Q & A:
© 2004 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Get documents about "