This document summarizes enhancements to the .NET Framework 4, covering topics such as LINQ, ASP.NET, WCF, WPF, ADO.NET, C#, VB.NET, the Common Language Runtime, garbage collection, and exception handling. It also discusses parallel programming enhancements, the System.Device.Location API, in-process side-by-side assemblies, primary interop assemblies, and code contracts. The presentation provides demonstrations of key features.
4. What are we covering? LINQ ASP.NET WCF WPF ADO.NET … C# VB.NET C++ DLR Base Class Libraries Common Language Runtime JITNGEN Garbage Collector Type System Exception handling Hosting APIs Loader and binder Debugging, …
5. PREP VS – with base project Open program.cs VS – With SxS Demo VS – With Movies (MEF) demo, do a build and remove some of the adapters from the output (put somewhere you can get them easily). Keep folder open VS – With location demo. Clean reflector
6. BIG INT Tour base [Ctrl+1] – talk about the big number and what happens when you try to go over it (overflow and exceptions). Point out decimal is a type value. decimal bigNumber = decimal.MaxValue; Console.WriteLine(bigNumber); bigNumber++; Console.WriteLine(bigNumber); Add reference to system.numerics (nice to point out performance of add reference dialog) [Ctrl+2] – change to big int. point out it is a class. Talk about static methods needed. Talk about no logical upperlimit BigIntegerbigInteger1 = new BigInteger(decimal.MaxValue); Console.WriteLine(bigInteger1); BigInteger bigInteger2 = new BigInteger(decimal.MaxValue); Console.WriteLine(bigInteger1 * bigInteger2); Console.WriteLine(BigInteger.Multiply(bigInteger1, bigInteger2)); LAZY<T> [Ctrl+3] Add the slow class [Ctrl+4] Add code to the main method to show the constructor is slow Console.WriteLine("Before slow create"); Slow slow = new Slow(); Console.WriteLine("After slow create"); slow.Message(); [Ctrl+5] Now change to implement Lazy<T> and show how it is not created until we actually use it. Console.WriteLine("Before slow create"); Lazy<Slow> slow = new Lazy<Slow>(); Console.WriteLine("After slow create"); Console.WriteLine(slow.IsValueCreated); slow.Value.Message(); Console.WriteLine(slow.IsValueCreated); Remove the main method and type sorted – nice to show intellisense filtering. Should have sortedlist, sorteddictionary and sortedset Talk about difference between sorting in a list which needs to check during actions and unbalanced binary tree which takes no perf hit on insert etc… and still gives great sorting perf. Also point out difference in requirements of keys for list/dictionary and objects in set.
7. IObserable SLIDE (1) – explain the pattern [Ctrl+6] Add data class [Ctrl+7] Add the provider class [Ctrl+8] Add the subscriber class [Ctrl+9] Add the code to the main method GPSSensor sensor = new GPSSensor(); Map map = new Map(); sensor.Subscribe(map, ConsoleColor.Red); //Map map2 = new Map(); //sensor.Subscribe(map2, ConsoleColor.Yellow); do { sensor.GetPosition(); Thread.Sleep(1000); } while (map.StillTracking); Uncomment to show second subscriber SxS Slide (1) – Explain the issue Switch to VS with loader demo. Tour the code start with the two assemblies, point out versions they are compiled to and what they do. Now show the Loader app and show the version (3.5). Show the code and point out that with reflection we are loading it – remind the audience to remember this stuff for later Run the app and note it points out v2 NOT 3.5 – cause the CLR hasn’t changed since 2. Click the run 3.5 assembly – works. Click run 4 assembly and note the exception. Now change the assembly version of loader to 4. and do stesp 4 and 5 again and it works! PIA Slide(1) – Explain what PIA is. Problems – rediretibution and size of distributable Go to VS [ALT +1 ] Add the count down method private static void CountDown() { Console.WriteLine("3..."); Thread.Sleep(1000); Console.WriteLine("2..."); Thread.Sleep(1000); Console.WriteLine("1..."); Thread.Sleep(1000); }
8. Add reference to Microsoft.Office.Interop.Excel – add version 14. Properties of the assembly and make sure embed is off. [ALT + 3] Add code to main method and talk through. Since it is automation explain the count down. Run and move back. Go to binary and drag into reflector – point out that it is listed under references which means shipping it. Go back to VS and change the assembly to embed. Build and demo to show it still works. Refresh reflector and show it has moved from references to actually embedding it into the project. Code Contracts [ALT + 4] Show the code and explain how the zune works out dates. [ALT + 5] Add code to call it in the main intdayInYear; intyear = ZuneDate.YearSince1980(300, out dayInYear); Console.WriteLine("It's the {0} day of {1}", dayInYear, year); Now change day to: 10593 and explain the bugon Dec 31 2008 [ALT + 6] – fully updated loop Add to start of loop: intdaysAtStart = daysLeft; Add to end of loop: Contract.Assert(daysLeft < daysAtStart); Now project and enable static code contract checking and build Point out the unproven issue – saying it thinks that there is a scenario that could fail [ALT + 7] Add the else to verify and build else { Contract.Assert(false); } It is the problem – so lets deal with it [ALT +8] Change the else contents to then build and show no errors. Now show dayInYear= 366; return year; Change day to -1 and show it doesn’t make sense. [ALT+9] Add to start of check: Contract.Requires(daysSince1980 > 0); Build and show how it identifies it – that is preconditions. Leave for now. [Ctrl+Alt+1] Add post conditions: Contract.Ensures(Contract.ValueAtReturn<int>(out dayInYear) > 0); Contract.Ensures(Contract.ValueAtReturn<int>(out dayInYear) < 367); Run and show that the code doesn’t fail even though our condition is not enforces the check. Pop into reflector and show that those conditions aren’t there. Turn on runtime checking and build and run – not the failure. Pop into reflector and show the code now and show the new code which has been added to the start and end! Mention sandcastle documentation tool support too
9. MEF Show folder with Movies project in it and run it. Add in the files we removed during the setup and run again. Remind people of reflection we saw before. Switch to VS with Movies Project and tour the code/ Explain we have an interface Show a provider implements it and is attributed with export. Show code of form and show the ImportMany attribute and talk about the initialisation (Catalog, container, and then we can loop over it). Parallel Open Task Manager Slides (1) – explain enhancements in parallel and why it is important Show hunt button code and explain that change it [Ctrl+Alt+2] Parallel.ForEach(movieProviders, movieProvider => { HighlightProvider(movieProvider, HighlightState.Searching); IEnumerable<MovieInfo> movies = movieProvider.Search(MovieNameTextBox.Text); HighlightProvider(movieProvider, HighlightState.Loading); AddRange(results, movies); HighlightProvider(movieProvider, HighlightState.None); }); Run and show in parallel Go to IMDB provider and show the LINQ query and explain that could also be parallele. [CTRL+ALT+3]: varmatchedLines = from l in File.ReadLines("movies.list").AsParallel() Build and show improvement (if any) Location Switch to location demo and tour that code and demo. PRAY
21. Location Windows 7 only Status will be Disabled for other platforms Geosense for Windows http://geosenseforwindows.com/
22. Is this everything? Support for Teredo All the new security enhancements in networking Garbage Collection Improved New ways to detect 64bit OS’s and processes Improvements to System.Enviroment Ngen Improved Memory Mapped Files New File and Directory Enumeration options based on generics Tuples F# New options for performance monitoring which are not invasive Improved parsing for GUID New helper method for Thread Improvements for Registries New helper method for Monitors Better stream compression options New helper methods for UIntPtr and IntPtr New helper method for System.IO.Path New helper method for Streams New helper method and parsing options for Enum New helper method for StopWatch New helper method for StringBuilder System.Numerics.Complex TimeSpanParsing Improvements String Improvements
25. We Want To Hear From You! Connect with Microsoft South Africa's Developer & Platform Group blogs.msdn.com/southafrica twitter.com/msdevsa Microsoft DevsSA Required Slide
26. Required Slide Win a Wireless Entertainment Desktop 8000! Complete your evaluation and enter to win!
27. Submit an Entry Form at the BB&D Stand and Win*!A Dell Netbook valued at R4,000 * Terms & conditions apply
BigRationalBigRational builds on the BigInteger introduced in .NET Framework 4 to create an arbitrary-precision rational number class.Long PathThis library provides functionality to make it easier to work with paths that are longer than the current 259 character limit.PerfMonitorPerfMonitor is a command-line tool for profiling the system using Event Tracing for Windows (ETW). PerfMonitor is built on top of the TraceEvent library.TraceEventAn library that greatly simplifies reading Event Tracing for Windows (ETW) events.