Microsoft NET Framework 4 Ahmed Salijee Developer Advisor httpdotnetorgzaahmeds aka NET4 Demofest What This Is Operating System Common Language Runtime Base Class Library ADONET and XML ID: 443060
Download Presentation The PPT/PDF document "DTL307:A Whirlwind Tour of the" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1Slide2
DTL307:A Whirlwind Tour of the Microsoft .NET Framework 4
Ahmed SalijeeDeveloper Advisorhttp://dotnet.org.za/ahmeds
aka .NET4
DemofestSlide3
What This IsSlide4
Operating System
Common Language Runtime
Base Class Library
ADO.NET and XML
ASP.NET
Web Forms Web Services
Mobile Controls
Windows
Forms
Common Language Specification
VB
C++
C#
J#
…
Visual Studio.NET
A Look Back…Slide5
.NET Framework 3.5 “Servicing Release”
WPF
Enhancements
.NET Framework 3.5
LINQ
WF & WCF Enhancements
Add-in
Framework
WPF 3.5
A Look Back
…
WPF
WCF
WF
CardSpace
.NET Framework 3.0
.NET Framework 2.0
SP1
SP1
Entity Framework
ADO. NET Data Services
ASP.NET MVCSlide6
A Look Back…
.NET 1.0
.NET 1.1
.NET 2.0
3.0
3.5
.NET 4
2002
2003
2009 Beta
2005-08
CLR 1.0
CLR 1.1
CLR 2.0
CLR 4
SP1Slide7
CLR/BCL
Data
Middle Tier/Services
Language Enhancements
User Interface
Languages
DLR
Type Equivalence
VarianceSlide8
Language - Variance, DynamicdemoSlide9
Common Language Runtime
Statically-Typed
C#
VB
Ruby
Python
Dynamically-Typed
Why the DLR?Slide10
Common Language Runtime
Statically-Typed
C#
VB
Ruby
Python
Dynamically-Typed
Dynamic Language Runtime
Why the DLR?Slide11
Python
Binder
Ruby
Binder
COM
Binder
Runtime
Binder
Runtime
Binder
.NET Dynamic Programming
Dynamic Language Runtime
Expression Trees
Dynamic Dispatch
Call Site Caching
Iron
Python
IronRuby
C#
VB.NET
Others…Slide12
Dynamically Typed Objects
Calculator calc = GetCalculator();
int
sum =
calc.Add
(10, 20);
object
calc =
GetCalculator
();Type
calcType = calc.GetType();object res = calcType.InvokeMember
(
"Add", BindingFlags.InvokeMethod, null, new
object[] { 10, 20 });int sum = Convert.ToInt32(res);
ScriptObject calc = GetCalculator();object res = calc.Invoke(
"Add"
, 10, 20);int sum = Convert.ToInt32(res);
dynamic calc = GetCalculator();int
sum = calc.Add(10, 20);Statically
typed to be dynamicDynamic method invocation
Dynamic conversionSlide13
Type EquivalenceInterop Assemblies translate between managed code and COM
For each interface, struct, enum, delegate, and member, contains a
managed equivalent with
marshalling dataSlide14
However! Primary Interop Assemblies cause many pain points…Slide15
Go Away, PIA!Compilers embed the portions of the
interop assemblies that the add-ins actually useRuntime
ensures
the embedded definitions of these types are
considered equivalentSlide16
C# Language Enhancements
object fileName
=
"Test.docx"
;
object
missing =
System.Reflection.
Missing
.Value;
doc.SaveAs(ref
fileName
, ref missing, ref missing, ref
missing, ref missing, ref missing,
ref missing, ref missing,
ref
missing, ref missing, ref
missing, ref missing, ref missing,
ref missing, ref missing,
ref missing);
namedRange.Find
("dog", xlByRows
,
MatchCase
:
True
);
Named argument
dynamic
result =
namedRange.Find
(
MatchCase
: True, what: "dog", searchOrder
: xlByRows
);
Arguments evaluated in order written
Named arguments can appear in any order
doc.SaveAs("Test.docx");Optional Paramsresult.ClearContents();
Late-binding through “dynamic” typeSlide17
Co- and Contra-variance
void Process(
object
[] objects) { … }
string
[] strings =
GetStringArray
();
Process(strings);
void
Process(
object
[] objects) { objects[0] = "Hello";
// Ok objects[1] = new Button
(); // Exception!}
List
<string> strings =
GetStringList();Process(strings);
void Process(
IEnumerable<object> objects) { … }
.NET arrays are co-variant…but
not safelyco-variantUntil now, C# generics have been invariant
void
Process(
IEnumerable
<
object
> objects) {
//
IEnumerable
<T> is read-only and
// therefore safely co-variant}
C# 4.0 supports safe co- and contra-varianceSlide18
Safe Co- and Contra-variance
public
interface
IEnumerable
<T>
{
IEnumerator
<T> GetEnumerator
();}
public
interface IEnumerator<T>{
T Current { get; } bool
MoveNext();}
public
interface
IEnumerable<out T>{
IEnumerator<T> GetEnumerator();
}
public interface IEnumerator
<out T>{ T Current {
get
; }
bool
MoveNext
();
}
out
= Co-variantOutput positions only
IEnumerable<
string> strings =
GetStrings
();
IEnumerable<object> objects = strings;Can be treated asless derived
public interface IComparer<T>{ int Compare(T x, T y);}
public interface IComparer<in T>{ int Compare(T x, T y);
}
IComparer<object> objComp = GetComparer();IComparer<string> strComp = objComp
;
in = Contra-variantInput positions onlyCan be treated asmore derivedSlide19
Let’s Fix It For Once And All!
string GetDescription
(
int
x) {
Contract
.Requires
( 0 < x );
Contract.Ensures(
Contract.Result<string
>()
!= null ); …}
Design-by-Contract meets .NET!Slide20
LanguagesSupport for DLRVariance – “things work the way you expect”Code ContractsMoving towards language parity – C#/VBFunctional Programming – F#
Better/Easier COM InteropSlide21
Data
Middle Tier/Services
Languages
Core Runtime/Class Library Enhancements
User Interface
CLR/BCL
Parallel
SxS
**
MEFSlide22
Parallel EnhancementsdemoSlide23
The Parallel Computing InitiativeLetting the brightest developers
solve business problems, not concurrency problems.
“Concurrency
for the masses”Slide24Slide25
Parallel Computing with .NET 4Task Parallel Library (TPL)Parallel LINQ (PLINQ)Coordination Data Structures (CDS)System.Threading ImprovementsSlide26
Parallel LINQParallel LINQ (PLINQ) enables developers to easily
leverage manycore with a minimal impact to existing LINQ programming model
var
q = from p in people
where
p.Name
==
queryInfo.Name
&&
p.State
==
queryInfo.State
&&
p.Year >= yearStart
&&
p.Year <= yearEnd
orderby
p.Year ascending
select p;
.AsParallel
()Slide27
MEFdemoSlide28
Managed Extensibility Framework? The Managed Extensibility Framework (MEF) is a new library
in the .NET Framework that enables greater reuse of applications and components. Using MEF, .NET applications can make the shift from being statically compiled to dynamically composedSlide29
MEF Basics…Export it.
Import it.Compose it.Slide30Slide31
Open/Closed PrincipleSoftware entities should be open for extension,
but closed for modification.Slide32
Known vs. UnknownSlide33
CLR/BCL
Middle Tier/Services
Languages
Data Enhancements
User Interface
Data
Model First
POCO*Slide34
Entity Framework – Model First and POCOdemoSlide35
In .NET 4.0 The next version of the Entity Framework
POCOLazy-loadingForeign KeysObjectSet<T> &
IObjectSet
<T>
Model FirstSlide36
CLR/BCL
Data
Languages
Middle Tier Enhancements
User Interface
Middle Tier/Services
Service Discovery
Workflow v4Slide37
Workflow v4demoSlide38
Moving Towards WF 4.0Major themes in WF 4.0 include…Slide39
New Flow Chart Model
Simple step-by-step model, with decisions and switches
Allows you to return to previous
activities in the workflow
Flowcharts offer a middle ground between
the sequential and state machine modelsSlide40
Arguments and Variables
Flow Chart
Parallel
Sequence
Send
Message
Delay
Receive
Message
Generate
Order
InArgument<TimeSpan>
OutArgument<Order>
InArgument<Message>
OutArgument<Message>
Process
Order
Send
Report
Variables
Variables
Variables
Activities are the primitive abstraction for behavior
Activities define
Arguments
to declare the type of data
that can flow into or out of an Activity
Activities are composable with other Activities
Activities have user-defined
Variables
for data storage
Activities bind Arguments
to in-scope VariablesSlide41
WCF Service DiscoverydemoSlide42
New WCF 4.0 FeaturesSimplified configurationDiscoveryRouter serviceImproved REST supportMisc. advanced featuresSlide43
Service DiscoveryWCF 4.0 provides two types of service discovery
Clients can discover services on a local subnet (UDP-based)
Clients can discover services on a larger "managed" network (beyond the local subnet) through a discovery proxy
Adhoc
Managed
Enabled via the
serviceDiscovery
behavior,
clients "discover" services using a
DynamicEndpointSlide44
CLR/BCL
Data
Middle Tier/Services
Languages
UI Enhancements
User Interface
WPF
ASP.NETSlide45
WPF – Controls and TouchdemoSlide46
WPF 4New ControlsDataGrid, DatePicker etcVisual State ManagerMulti-Touch
Windows 7 EnhancementsTasklists (Beta 2)Dialog BoxesText Enhancements in Beta 2Slide47
ASP.NET EnhancementsdemoSlide48
ASP.NET 4.0ASP.NET 4.0 WebFormsControl Rendering, Control IDsView State
Website URLsXHTML and AccessibilityAJAXClient-Side Templates, Controls and Data BindingRead/Write Database Data from the BrowserCross-Browser Compatible
Not tied to ASP.NETSlide49
ASP.NET AJAXClient-Side TemplatesClient-Side ControlsClient-Side Data BindingRead/Write Database Data from the BrowserCross-Browser Compatible
Not tied to ASP.NET
Client-Side
AJAXSlide50
AJAX 4 - Client TemplatesServer-Side (
WebForms):
<
ItemTemplate
>
<
li
>
<%#
Eval
("Name") %></li>
</
ItemTemplate>
Client-Side<
ul class="
sys-template
"> <
li>
{{ Name }}</li
></
ul>Slide51
AJAX 4 - DataContext
ASMX
WCF
ADO.NET
Data
Services
ASP.NET MVC
JsonResult
Etc.
1. Request
2. JSON Data
Data
Context
3. Modify
Data
4. Save Data
*
DataContext
includes change tracking automaticallySlide52
Data
Middle Tier/Services
Languages
Core Runtime/Class Library Enhancements
User Interface
CLR/BCL
Parallel
SxS
**
MEFSlide53
CLR InProcdemoSlide54
CLR 4 - In-Process Side-By-Side
.NET 2.0
.NET 4.0
2.0
add-in
3.0
3.5
Host Process (i.e. Outlook)
3.0
add-in
3.5
add-in
4.0
add-inSlide55Slide56
ResourcesWill post on http://dotnet.org.za/ahmedsOther breakouts will have more detailsSlide57
Related Sessions ( .NET 4)
WhenWhat Area
Code
Mon 8:00
Future Directions for Visual Basic
Languages
DTL308
Mon 17:15
The State of Dynamic Languages on the Microsoft .NET Framework
LanguagesDTL304 Tues 9:15Introduction to F#Languages
DTL:319Tues 16:15The Future of C#LanguagesDTL310Mon 9:15
The Manycore
Shift: Making Parallel Computing MainstreamCLR/BCLDTL206Tues 17:30Managed Extensibility FrameworkCLR/BCLDTL315Tues 14:30A First Look at WCF and WF in the Microsoft .NET Framework 4.0
MiddleSOA201Mon 17:15The ADO.NET Entity Framework 4DataDTL402Tues 17:30An Introduction to the ADO.NET Data Services Framework v1.5
DataDTL208Slide58
Related Sessions ( .NET 4)TIme
TopicAreaCodeMon 15:45
Building Scalable and Available Web Applications with the Microsoft Code Name "Velocity"
Web
WUX301
Tues 10:50
A Lap around Microsoft ASP.NET 4.0 and Microsoft Visual Studio 2010
Web
WUX203
Wed 9:00Taking AJAX to the Next Level**WebWUX306Mon 8:00
Building Rich Business Clients in WPF: New Tools and Controls for Windows Presentation Foundation ClientWUX303 Tues 13:15Microsoft Visual Studio 2010 Overview for the Business Application DeveloperGeneral
DTL309Slide59
Required Slide
Complete a session evaluation and enter to win!
10 pairs of MP3
sunglasses
to be
wonSlide60
www.microsoft.com/teched
Sessions On-Demand & Community
http://microsoft.com/technet
Resources for IT Professionals
http://microsoft.com/msdn
Resources for Developers
www.microsoft.com/learning
Microsoft Certification & Training Resources
Resources
Required Slide
Speakers,
TechEd 2009 is not producing
a DVD. Please announce that
attendees can
access session
recordings at TechEd Online.
www.microsoft.com/learning
Microsoft Certification and Training
R
esourcesSlide61
©
2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
MICROSOFT
MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Required Slide