1 / 67

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 kcasada@microsoft.com http://blogs.msdn.com/swiss_dpe_team/Default.aspx. Introduction. 3.5. 3.0. .NET 1.0. .NET 1.1. .NET 2.0. .NET 4.0. 2002. 2003. 2005-08. ~ < 2009.

Download Presentation

First look at Visual Studio 2010 and .NET Framework 4.0

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. First look at Visual Studio 2010 and .NET Framework 4.0 Ken Casada Developer Evangelist Microsoft Switzerland kcasada@microsoft.com http://blogs.msdn.com/swiss_dpe_team/Default.aspx

  2. Introduction 3.5 3.0 .NET 1.0 .NET 1.1 .NET 2.0 .NET 4.0 2002 2003 2005-08 ~ < 2009 CLR 1.0 CLR 1.1 CLR 2.0 CLR 4.0

  3. Existing Side-By-Side (SxS) 1.1 add-in 2.0 add-in 3.0 add-in 3.5 add-in 3.5 .NET 1.1 3.0 .NET 2.0 Host Process (e.g. Outlook)

  4. In-Process Side-By-Side (SxS) 2.0 add-in 3.0 add-in 3.5 add-in 4.0 add-in 3.5 .NET 4.0 3.0 .NET 2.0 Host Process (e.g. Outlook)

  5. .NET DynamicProgramming Dynamic vs. Static

  6. C# and Visual Basic Focusing on language co-evolution…

  7. Parallel Programming 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

  8. Parallel LINQ demo

  9. .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)  http://www.codeplex.com/wpf • 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, …

  10. WPF 4.0within Visual Studio 2010 demo

  11. 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!!!

  12. Microsoft Touch Pack for Windows 7 demo

  13. WCF … let’sstartwith a demo

  14. 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.

  15. WCF 4.0 (DemoSummary) • Enables file less activation (no .svc) in case of IIS-WAS hosted Web Services!!! <system.serviceModel> <serviceHostingEnvironment> <serviceActivations> <add relativeAddress="/MyService.svc" service="ServiceTypeName"/> <add relativeAddress="/MyService" service="ServiceTypeName"/> </serviceActivations> </serviceHostingEnvironment> </system.serviceModel>

  16. 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: http://code.msdn.microsoft.com/wcfwf4)

  17. 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

  18. WCF 4.0: Routing Service demo

  19. 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 !!!!

  20. 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

  21. 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

  22. Workflow Services demo

  23. WF Scenario CLIENT SERVER

  24. 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

  25. 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

  26. Dublin (after .NET 4)

  27. Microsoft Confidential Additional Resources • MSDN Developer Centers – .NET 3.5http://msdn.microsoft.com/wcfhttp://msdn.microsoft.com/wf • MSDN Developer Centers – .NET 4.0http://msdn.microsoft.com/wcf/future/http://msdn.microsoft.com/wf/future/ • WF/WCF Team Bloghttp://blogs.msdn.com/endpoint/ • Dublin http://www.microsoft.com/net/dublin.aspx

  28. Office development (No PIA)

  29. Start again at 11:00 with C# 4.0 and EF v2 Break 

  30. What's new in C# 4.0?

  31. The Evolution of C# C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code

  32. Trends

  33. The Evolution of C# C# 4.0 Dynamic Programming C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code

  34. C# 4.0 Language Innovations • Dynamically Typed Objects • Optional and Named Parameters • Improved COM Interoperability • Co- and Contra-variance

  35. .NET Dynamic Programming IronPython IronRuby C# VB.NET Others… Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching ObjectBinder JavaScriptBinder PythonBinder RubyBinder COMBinder

  36. 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

  37. 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

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

  39. IDynamicObject 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); publicMetaObjectIDynamicObject.GetMetaObject(); }

  40. Implementing IDynamicObject demo

  41. Optional and Named Parameters Primary method publicStreamReaderOpenTextFile( string path, Encodingencoding, booldetectEncoding, intbufferSize); Secondary overloads publicStreamReaderOpenTextFile( string path, Encodingencoding, booldetectEncoding); publicStreamReaderOpenTextFile( string path, Encodingencoding); publicStreamReaderOpenTextFile( string path); Call primary with default values

  42. Optional and Named Parameters publicStreamReaderOpenTextFile( 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 OpenTextFile( bufferSize: 4096, path: "foo.txt", detectEncoding: false); Non-optional must be specified

  43. Improved COM Interoperability objectfileName = "Test.docx"; object missing = System.Reflection.Missing.Value; doc.SaveAs(reffileName, 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); doc.SaveAs("Test.docx");

  44. 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];

  45. Co- and Contra-variance .NET arrays are co-variant string[] strings = GetStringArray(); Process(strings); …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(); Process(strings); 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) { … }

  46. Safe Co- and Contra-variance publicinterfaceIEnumerable<T> { 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; } boolMoveNext(); } publicinterfaceIEnumerator<T> { T Current { get; } boolMoveNext(); } IEnumerable<string> strings = GetStrings(); IEnumerable<object> objects = strings; in= Contra-variantInput positions only publicinterfaceIComparer<T> { 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;

  47. Variance in C# 4.0 • Supported for interface and delegate types • Value types are always invariant • IEnumerable<int> is notIEnumerable<object>

  48. Variance in .NET Framework 4.0 Interfaces 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> Delegates System.Func<in T, …, out R> System.Action<in T, …> System.Predicate<in T> System.Comparison<in T> System.EventHandler<in T>

  49. The Evolution of C# C# 4.0 Dynamic Programming C# 3.0 Language Integrated Query C# 2.0 Generics C# 1.0 Managed Code

  50. Additional Resources • C# 4.0 Samples and Whitepaper • http://code.msdn.microsoft.com/csharpfuture • Visual C# Developer Center • http://csharp.net • C# team member’s blogs • http://blogs.msdn.com/ericlippert/ • http://blogs.msdn.com/cburrows/ • http://blogs.msdn.com/samng/ • http://blogs.msdn.com/sreekarc/ • http://blogs.msdn.com/mattwar/ • http://blogs.msdn.com/ed_maurer/ • http://blogs.msdn.com/davsterl/ • http://blogs.msdn.com/alexghi

More Related