First look at visual studio 2010 and net framework 4 0
1 / 67

First look at Visual Studio 2010 and .NET Framework 4.0 - PowerPoint PPT Presentation

  • Uploaded on

First look at Visual Studio 2010 and .NET Framework 4.0. Ken Casada Developer Evangelist Microsoft Switzerland [email protected] Introduction. 3.5. 3.0. .NET 1.0. .NET 1.1. .NET 2.0. .NET 4.0. 2002. 2003. 2005-08. ~ < 2009.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about ' First look at Visual Studio 2010 and .NET Framework 4.0' - zephr-horton

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
First look at visual studio 2010 and net framework 4 0

First look at Visual Studio 2010 and .NET Framework 4.0

Ken Casada

Developer Evangelist

Microsoft Switzerland

[email protected]




.NET 1.0

.NET 1.1

.NET 2.0

.NET 4.0




~ < 2009

CLR 1.0

CLR 1.1

CLR 2.0

CLR 4.0

Existing side by side sxs
Existing Side-By-Side (SxS)

1.1 add-in

2.0 add-in

3.0 add-in

3.5 add-in


.NET 1.1


.NET 2.0

Host Process (e.g. Outlook)

In process side by side sxs
In-Process Side-By-Side (SxS)

2.0 add-in

3.0 add-in

3.5 add-in

4.0 add-in


.NET 4.0


.NET 2.0

Host Process (e.g. Outlook)

Net dynamic programming
.NET DynamicProgramming

Dynamic vs. Static

C and visual basic
C# and Visual Basic

Focusing on language co-evolution…

Parallel Extensions is a .NET Library that supports declarative and imperative data parallelism, imperative task parallelism, and a set of data structures that make coordination easier.

  • Parallel LINQ (PLINQ)

  • Task Parallel Library (TPL)

  • Coordination Data Structures (CDS)

    Parallel Extension June 2008 CTP

Net framework 4 0 client
.NET Framework 4.0: Client

  • Client Profile

  • Windows Presentation Foundation

    • Business focused controls

      • DataGrid, DatePicker, VSM

         Today part of the WPF Toolkit (update in March 09)


      • After .NET 4.0  More controls (Chart controls, …)

    • Silverlight Synergy

      • DeepZoom in WPF 4.0 has been cut

    • Deploy Full-Trust XBAP: ClickOnceelevation prompt isenabledfor (XBAPs) in Intranet and Trusted Zones.

    • And More: text enhancements for much clearer text rendering, …

  • Wpf 4 0 within visual studio 2010

    WPF 4.0within Visual Studio 2010


    Multi touch

    • Windows 7 Multi-Touch API

    • WPF 4.0 Multi-Touch API and Controls

      • Base WPF controls updated to be multi-touch aware

      • Multi-Touch specific new controls

      • Surface SDK 2.0 built on top of WPF 4.0

        Windows 7 RC Training Kit for Developers

        Just Released!!!

    Wcf let s start with a

    WCF … let’sstartwith a


    Wcf 4 0 demo summary
    WCF 4.0 (Demo Summary)

    • Simplified Configurations

      • No more need for <service> tag to configure a service.

      • Default Endpoints for each base Address and implemented contract

    • Standard Endpoints

      • mexEndpoint

      • webHttpEndpoint

      • discoveryEndpoint

        …and more…

        <system.serviceModel>    <services>        <service name=“MyService"><endpointkind="mexEndpoint" />        </service>    </services> </system.serviceModel>

     pre-defined endpoints that have one or more of their properties (address, binding, contract) fixed.

    Wcf 4 0 demo summary1
    WCF 4.0 (DemoSummary)

    • Enables file less activation (no .svc)

      in case of IIS-WAS hosted Web Services!!!




      <add relativeAddress="/MyService.svc" service="ServiceTypeName"/>

      <add relativeAddress="/MyService" service="ServiceTypeName"/>




    Wcf 4 0
    WCF 4.0

    • Service Discovery (WS-Discovery)

      • Ad-hoc discovery (multicast)

         clients can discover services on a local subnet (UDP-based)

      • Proxy-managed discovery (unicast)

         clients can discover services on a larger "managed" network (beyond the local subnet) through a discovery proxy (dedicated network resource). Allow you to locate services no matter whey are.

      • Announcements

        • You can add an announcement endpoint (standard Endpoint: udpAnnouncementEndpoint), which guarantees that the service will send an online and offline announcement when the service is opened and closed respectively. As a service consumer you get notified when the service endpoints go on- and offline.

      • WCF Service Discovery HOL available within the WCF-WF 4 Beta 1 Training Kit:

    Wcf 4 01
    WCF 4.0

    • Improved REST support

      • Many features from the WCF REST Starter Kit will become part of WCF 4.0.

         WCF REST Starter Kit Preview 2 available on Codeplex

    • Correlation enhancements

      • Content and context driven

    • Integration with Workflow Services

    • Router Service supporting

      • Content-based routing

        • Able to perform message filtering based on the content contained within the message (SOAP header/message body)

      • Protocol Bridging

    Wcf 4 0 routing service

    WCF 4.0: Routing Service


    Wcf 4 0 demo summary2
    WCF 4.0 (DemoSummary)

    • Create a CalculatorService listening at

    • http://localhost:8000/servicemodelsamples/service

    • Create a RoutingService (of type RountingService)listeningathttp://localhost:8000/routingservice/router

    • Create a RoutingTable within the app.config file of the RountingServiceApp, whichredirect all incoming messages to the CalculatorService.

    • Create a Client Application

    • a) create a proxy class (Add Service Reference to the Calculator Service)

    • b) create a client Endpointwith

    • (A)ddress: routing service (http://localhost:8000/routingservice/router )

    • (B)inding: routing service

    • (C)ontract: calculatorcontract

    • The client does not know anything about the CalculatorService besides the contract of course !!!!

    Workflow foundation 4 0
    Workflow Foundation 4.0

    • XAML-only workflows are the new default

      • Unified model between WF, WCF, and WPF

    • Extended base activity library

      • More activities will be present on CodePlex

    • WF 4.0 simplifies data flow by adding:

      • Arguments, variables, and expressions

      • Significant improvements in performance and scalability

      • New FlowChart Workflow

    • Improved WF 4.0 designer / Designer Rehosting

    Wcf and wf
    WCF and WF

    • There is great potential in WF + WCF

      • .NET 3.0 didn't provide any integration

      • .NET 3.5 added initial WCF support

      • .NET 4.0 is investing heavily in this area

         Workflow Services !!!

    • Think "WCF on the outside, WF on the inside"

      • WCF exposes external interface

      • WF describes internal flow & state transitions

    Workflow services

    Workflow Services


    Wf scenario

    WF Scenario



    Wf 3 0 in net 4 3 scenarios
    WF 3.0 in .NET 4  3 Scenarios

    • Stick with WF3.x workflow model

    • Interop: Use WF3.x artifacts in WF4 solutions

    • Rewrite WF3.x activities and workflows

      Migration guidance for WF Developers

    Dublin after net 4
    Dublin (after .NET 4)

    • IIS 7/WAS is today’s hosting environment for WCF service and WF workflows (WorkflowServiceHost class)

    • Provides valuable hosting and management features for your WCF and WF applications

    • Part of the Windows Server Application Server role

    • Extensions built on top of IIS 7 with tracing, monitoring and diagnostic capabilities

    Additional resources

    Microsoft Confidential

    Additional Resources

    • MSDN Developer Centers – .NET 3.5

    • MSDN Developer Centers – .NET 4.0

    • WF/WCF Team Blog

    • Dublin

    Start again at 11 00 with c 4 0 and ef v2

    Start again at 11:00 with C# 4.0 and EF v2

    Break 

    The evolution of c
    The Evolution of C#

    C# 3.0

    Language Integrated Query

    C# 2.0


    C# 1.0

    Managed Code

    The evolution of c1
    The Evolution of C#

    C# 4.0

    Dynamic Programming

    C# 3.0

    Language Integrated Query

    C# 2.0


    C# 1.0

    Managed Code

    C 4 0 language innovations
    C# 4.0 Language Innovations

    • Dynamically Typed Objects

    • Optional and Named Parameters

    • Improved COM Interoperability

    • Co- and Contra-variance

    Net dynamic programming1
    .NET Dynamic Programming






    Dynamic Language Runtime

    Expression Trees

    Dynamic Dispatch

    Call Site Caching






    Dynamically typed objects
    Dynamically Typed Objects

    Calculator calc = GetCalculator();

    int sum = calc.Add(10, 20);

    object calc = GetCalculator();

    TypecalcType = calc.GetType();

    object res = calcType.InvokeMember("Add",

    BindingFlags.InvokeMethod, null,

    newobject[] { 10, 20 });

    int sum = Convert.ToInt32(res);

    ScriptObject calc = GetCalculator();

    object res = calc.Invoke("Add", 10, 20);

    int sum = Convert.ToInt32(res);

    Statically typed to be dynamic

    dynamic calc = GetCalculator();

    int sum = calc.Add(10, 20);

    Dynamic conversion

    Dynamic method invocation

    Dynamically typed objects1
    Dynamically Typed Objects

    Compile-time typedynamic

    Run-time typeSystem.Int32

    dynamic x = 1;

    dynamic y = "Hello";

    dynamic z = newList<int> { 1, 2, 3 };

    • When operand(s) are dynamic…

    • Member selection deferred to run-time

    • At run-time, actual type(s) substituted for dynamic

    • Static result type of operation is dynamic

    Dynamically typed objects2
    Dynamically Typed Objects

    public static class Math


    publicstaticdecimal Abs(decimal value);

    publicstaticdouble Abs(double value);

    publicstaticfloat Abs(float value);

    publicstaticint Abs(int value);

    publicstaticlong Abs(long value);

    publicstaticsbyte Abs(sbyte value);

    publicstaticshort Abs(short value);



    Method chosen at compile-time:double Abs(double x)

    double x = 1.75;

    double y = Math.Abs(x);

    Method chosen at run-time: double Abs(double x)

    dynamic x = 1.75;

    dynamic y = Math.Abs(x);

    Method chosen at run-time:int Abs(int x)

    dynamic x = 2;

    dynamic y = Math.Abs(x);


    publicabstractclassDynamicObject : IDynamicObject


    publicvirtualobjectGetMember(GetMemberBinder info);

    publicvirtualobjectSetMember(SetMemberBinder info, object value);

    publicvirtualobjectDeleteMember(DeleteMemberBinder info);

    publicvirtualobjectUnaryOperation(UnaryOperationBinder info);

    publicvirtualobjectBinaryOperation(BinaryOperationBinder info, objectarg);

    publicvirtualobject Convert(ConvertBinder info);

    publicvirtualobject Invoke(InvokeBinder info, object[] args);

    publicvirtualobjectInvokeMember(InvokeMemberBinder info, object[] args);

    publicvirtualobjectCreateInstance(CreateInstanceBinder info, object[] args);

    publicvirtualobjectGetIndex(GetIndexBinder info, object[] indices);

    publicvirtualobjectSetIndex(SetIndexBinder info, object[] indices, object value);

    publicvirtualobjectDeleteIndex(DeleteIndexBinder info, object[] indices);



    Implementing idynamic object

    Implementing IDynamicObject


    Optional and named parameters
    Optional and Named Parameters

    Primary method


    string path,




    Secondary overloads


    string path,




    string path,



    string path);

    Call primary with default values

    Optional and named parameters1
    Optional and Named Parameters


    string path,

    Encodingencoding = null,

    booldetectEncoding = true,

    intbufferSize = 1024);

    Optional parameters

    Named argument

    OpenTextFile("foo.txt", Encoding.UTF8);

    OpenTextFile("foo.txt", Encoding.UTF8, bufferSize: 4096);

    Named arguments can appear in any order

    Arguments evaluated in order written

    Named arguments must be last


    bufferSize: 4096,

    path: "foo.txt",

    detectEncoding: false);

    Non-optional must be specified

    Improved com interoperability
    Improved COM Interoperability

    objectfileName = "Test.docx";

    object missing = System.Reflection.Missing.Value;


    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);


    Improved com interoperability1
    Improved COM Interoperability

    • object  dynamic mapping

    … you can now say

    excel.Cells[1, 1].Value = "Hello";

    instead of

    ((Excel.Range)excel.Cells[1, 1]).Value2 = "Hello";

    … and

    Excel.Range range = excel.Cells[1, 1];

    instead of

    Excel.Range range = (Excel.Range)excel.Cells[1, 1];

    Co and contra variance
    Co- and Contra-variance

    .NET arrays are co-variant

    string[] strings = GetStringArray();


    …but not safelyco-variant

    void Process(object[] objects) {

    objects[0] = "Hello"; // Ok

    objects[1] = newButton(); // Exception!


    void Process(object[] objects) { … }

    Until now, C# generics have been invariant

    List<string> strings = GetStringList();


    C# 4.0 supports safe co- and contra-variance

    void Process(IEnumerable<object> objects) {

    // IEnumerable<T> is read-only and

    // therefore safely co-variant


    void Process(IEnumerable<object> objects) { … }

    Safe co and contra variance
    Safe Co- and Contra-variance



    IEnumerator<T> GetEnumerator();


    publicinterfaceIEnumerable<out T>


    IEnumerator<T> GetEnumerator();


    out= Co-variantOutput positions only

    Can be treated asless derived

    publicinterfaceIEnumerator<out T>


    T Current { get; }





    T Current { get; }



    IEnumerable<string> strings = GetStrings();

    IEnumerable<object> objects = strings;

    in= Contra-variantInput positions only



    int Compare(T x, T y);


    publicinterfaceIComparer<in T>


    int Compare(T x, T y);


    Can be treated asmore derived

    IComparer<object> objComp = GetComparer();

    IComparer<string> strComp = objComp;

    Variance in c 4 0
    Variance in C# 4.0

    • Supported for interface and delegate types

    • Value types are always invariant

      • IEnumerable<int> is notIEnumerable<object>

    Variance in net framework 4 0
    Variance in .NET Framework 4.0


    System.Collections.Generic.IEnumerable<out T>

    System.Collections.Generic.IEnumerator<out T>

    System.Linq.IQueryable<out T>

    System.Collections.Generic.IComparer<in T>

    System.Collections.Generic.IEqualityComparer<in T>

    System.IComparable<in T>


    System.Func<in T, …, out R>

    System.Action<in T, …>

    System.Predicate<in T>

    System.Comparison<in T>

    System.EventHandler<in T>

    The evolution of c2
    The Evolution of C#

    C# 4.0

    Dynamic Programming

    C# 3.0

    Language Integrated Query

    C# 2.0


    C# 1.0

    Managed Code

    Additional resources1
    Additional Resources

    • C# 4.0 Samples and Whitepaper


    • Visual C# Developer Center


    • C# team member’s blogs









    Ado net entity framework
    ADO.NET Entity Framework

    Entity Data Model

    • Entity Data Model

      • Define your application model

        • Map it to a persistence store

      • Comprised of 3 layers (XML files):

        • Conceptual (CSDL)

        • Mapping (MSL)

        • Storage (SSDL)

      • Databaseagnostic

        • Databasevendors are developing providers …


      • Twoquery options:

        • Entity SQL

        • LINQ To Entities




    Linq to entities


    from c in db.Customers

    where c.City == "London"

    select c.CompanyName


    c2.City = "Barcelona";


    LINQ Query



    Entity Data Model

    SQL Query


    DML or SProcs

    SELECT CompanyName

    FROM Cust

    WHERE City = 'London'

    INSERT INTO Cust …


    DB (for instance SQL Server)

    Lazy loading in ef v1
    Lazy Loading in EF v1

    varcustomers = fromcustindb.Customers where cust.City == “London"select cust;

    foreach (Customercust in customers)

    {// avoidsunnecessaryqueries

    if (!cust.Orders.IsLoaded){cust.Orders.Load();} 

    foreach (Orderorder in cust.Orders){ // do somethingwithdetail}


    Lazy loading in ef v2
    Lazy Loading in EF v2

    varcustomers = fromcustindb.Customers where cust.City == “London"select cust;

    db.ContextOptions.DeferredLoadingEnabled = true;

    foreach (Customercust in customers)

    {foreach (Orderorder in cust.Orders){ // do somethingwithdetail}


    Entity framework v2
    Entity Framework v2

    • Automatic Lazy Loading, Pluralization

    • Foreign Key Support

    • Persistent Ignorance (POCO)

      • POCO Experience in EF v2 – Part 1

      • POCO Experience in EF v2 – Part 2

        … More to come on

    • N-tier Support

      • Self-Tracking Entities (Smart entity objects which track their own changes & changes to related entities)

    Self tracking entities in ef v2 mid tier
    Self-tracking Entities in EF v2 (mid-tier)

    interface ICustomerService


    Customer GetCustomer(string customerID);

    voidUpdateCustomer(Customer customer);


    Self tracking entities in ef v2 mid tier1
    Self-tracking Entities in EF v2 (mid-tier)

    public Customer GetCustomer(string customerID)


    using (NorthwindEntitiescontext=new NorthwindEntities())


    var result = context.Customers.


    Single(c => c.CustomerID == customerID);

    return result;



    public voidUpdateCustomer(Customer customer)


    using (NorthwindEntitiescontext=new NorthwindEntities())






    Self tracking entities in ef v2 client
    Self-tracking Entities in EF v2 (client)

    public voidDeleteObjectsTexts()


    using(CustomerServiceClientclient=new CustomerServiceClient())


    var customer= client.GetCustomer("ALFKI");





    The resultingentity graph is sent back to the service tierusing the UpdateCustomermethod!!!

    Entity framework v21
    Entity Framework v2

    • Code Generation(T4 templates support)

      • Completely replace entity framework code generation with custom code

      • Generate POCO classes from the model to use as a starting point in my applications

      • Generate self-tracking entity classes

    Entity framework v22
    Entity Framework v2

    • Code GenerationT4 templates support, but No Editor Support

      • 3rd party solutions which provides T4 Editors:


        • (Tangible T4 Editor now listed in Visual Studio 2010 Beta 1 Extension Manager)

    Entity framework v23
    Entity Framework v2

    • Model Defined Functions

    • Model First Development

    • Complex Types

    varresults = from person indb.People where GetAge(person) > 35select person;

    GetAge must be defined within the CSDL File (Sample)

    Resources ef
    Resources (EF)

    • MSDN Documentation

      • What’s New in ADO.NET

    • ADO.NET Blog


    • EF Design Blog


    • Data Developer Center


    • Entity Framework HOL


    Msdn ressources
    MSDN Ressources

    PresentationsMSDN Events PresentationfinderMSDN Webcasts

    Upcoming EventsTechEd Europe 2009, 9 – 13 November in Berlin

    MSDN FlashSign up (bi-weekly newsletter)

    MSDN Team BlogRSS:

    Developer User Groups & CommunitiesMobile DevicesMicrosoft Solutions User Group Switzerland.NET Managed User Group of SwitzerlandFoxPro User Group Switzerland