530 likes | 760 Views
Microsoft .NET Framework 2.0. Neno Loje Microsoft Student Partner Universität Hamburg. Was ist „Whidbey“?. Code Name für … die nächste Version vom .NET Framework … die nächste Version von C#, Visual Basic .NET … die nächste Version von Visual Studio. Voraussichtliche Produktnamen
E N D
Microsoft .NET Framework 2.0 Neno Loje Microsoft Student Partner Universität Hamburg
Was ist „Whidbey“? Code Name für • … die nächste Version vom .NET Framework • … die nächste Version von C#, Visual Basic .NET • … die nächste Version von Visual Studio Voraussichtliche Produktnamen • … .NET Framework 2.0 • … Visual Studio 2005
Agenda Was ist neu in… ? • … .NET Framework (BCL) • … Spracherweiterungen / CTS • … Windows Forms 2.0 • … ASP.NET 2.0 • … ADO.NET 2.0 • … Visual Studio 2005 • … Noch einiges mehr
Drucken ist erheblich einfacher Visual Basic .NET 2003 Visual Basic “Whidbey” Private Sub Button1_Click(…) Handles Button1.Click PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.ShowDialog() End Sub Private Sub PrintDocument1_PrintPage(…) Handles PrintDocument1.PrintPage Dim font As New Font("Arial", 10) Dim brush As Brush = Brushes.Black Dim X As Integer = 50 Dim Y As Integer = 50 Dim LineHeight As Integer = 20 With e.Graphics .DrawString("Circuit Board ID: " & _ txtCircuitBoardID.Text, font, _ brush, X, Y) Y = Y + LineHeight .DrawString("Date Printed: " & Now, font, _ brush, X, Y) Y = Y + LineHeight .DrawImage(PictureBox1.Image, X, Y) Y = Y + LineHeight + _ PictureBox1.Image.Height .DrawLine(Pens.Black, X, Y, 750, Y) Y = Y + LineHeight .DrawString("Test Data", font, brush, X, Y) Y = Y + LineHeight .DrawString(TextBox1.Text, font, brush, X, Y) End With End Sub Private Sub Button1_Click(…) Handles Button1.Click With My.Computer.Printer .WriteLine("Circuit Board ID: " & _ txtCircuitBoardID.Text) .WriteLine("Date Printed: " & Now) .WriteLine(PictureBox1.Image) .WriteHorizontalLine(Height:=3) .WriteLine("Test Data") .WriteLine(TextBox1.Text) .Print(PreviewDialog:=True) End With End Sub
The .NET FrameworkA Once in a Decade Change Windows3.0 • PDC 2000 Paradigm Shift • Web services • Managed Code Services Components Richness MFC APIs COM Win32 Win16 1980 1990 2000
Landmarks To Date • Running in over 60% of Fortune 100 • More than 70M systems with .NET Framework • Strong developer ecosystem • ISO standardization
Tools .NET Framework “Whidbey” Client Application Model Web & Service Application Model Data Systems Application Model Mobile PC & Devices Application Model Command Line Compact Framework System.Console Yukon Windows Forms ASP.NET NTService System.Data.SqlServer System.Web System.Windows.Forms System.Windows.Forms System.ServiceProcess Communication Presentation Data System.Messaging System.Data System.Web.UI System.DirectoryServices System.Runtime.Remoting SqlClient DataSet Page WebControls SqlTypes Mapping Control Adaptors System.Web.Services SqlXML ObjectSpaces HtmlControls Design Web.Service Description OdbcClient ObjectSpace MobileControls Discovery OleDbClient Query Protocols System.Windows.Forms OracleClient Schema Forms System.Net System.Xml System.Web Control HttpWebRequest NetworkInformation Schema Xpath Personalization Print Dialog Serialization FtpWebListener Sockets Query Caching Design SslClientStream Cache SessionState WebClient System.Drawing Fundamentals Security Base & Application Services Configuration Deployment/Management System.Timers System.Text System.Web.Security System.Web.Configuration System.Collections System.Web System.Security System.Globalization System.Design Generic System.Configuration Administration AccessControl Permissions System.Serialization System.IO Management System.Resources System.ComponentModel Policy Credentials System.Threading Ports System.CodeDom Cryptography Principal System.Management System.Runtime System.Reflection Token System.Deployment Serialization InteropServices System.EnterpriseServices System.Diagnostics CompilerServices System.Transactions
Base Innovations • 64-bit Support • Performance • Edit and Continue • Base Library Enhancements • Generics TODO -- Slide 8 with the a few namespaces highlighted
Innovations In Data Access • ADO.NET • No Model Changes • Advanced Features • Performance • System.Xml • Performance • XQuery • ObjectSpaces • Builds on ADO.NET • Domain objects: Customer, Order, Address
Innovations In Data Access:SQL Server “Yukon” • Extend SQL’s type system, stored procs, functions, triggers in managed code • Leverage broad developer ecosystem • Wide choice of languages • Visual Basic, C#, MC++, COBOL, …and T-SQL • Leverages much of the .NET Framework • BCL, network access, Web services… • Enable third parties to write libraries to extend the DB
Innovations On The WebASP.NET Whidbey • Reduce plumbing code by 70% • Building Blocks • Page Framework • 40+ New ASP.NET controls
Innovations For Devices • Mobile capabilities for all ASP.NET controls • Tablet PC SDK extends the core Framework • Improvements in .NET Compact Framework security, performance and interoperability
Road To Longhorn Windows3.0 • All building on the .NET Framework • Delivering amazing new user experiences with Avalon • Extending Web services to the client with Indigo • Everyday info with WinFS WinFX Services Components Richness .NET Framework “Whidbey” APIs MFC COM Win32 Win16
Related Longhorn Era Technologies • Windows Forms • Works great on Longhorn! • Two-way interop with Avalon • See: CLI391 Windows Forms: Exploiting Windows “Longhorn” Features from Within Your Application • ASMX, .NET Remoting and Enterprise Services • All work great on Longhorn! • Indigo unifies RPC style programming • See: WSV203 “Indigo”: Connected Application Technology Roadmap
Summary • Whidbey Design Goals • Deliver on the Fundamentals: Security, Deployment, Manageability, Performance • Enhanced Productivity • Path to the Future WinFX
Tools Command Line Client Application Model Web & Service Application Model Data Systems Application Model Mobile PC & Devices Application Model Compact Framework System.Console Win FS Yukon Mobile PC Optimized Avalon Windows Forms ASP.NET / Indigo NTService System.Data.SqlServer System.Windows.Forms System.Windows System.Storage System.Web System.Windows System.Windows.Forms System.ServiceProcess Communication Data Presentation System.Collaboration System.Search System.Discovery System.Data System.Windows System.Messaging SqlClient DataSet RealTimeEndpoint UI Element Explorer Media Annotations System.DirectoryServices ActiveDirectory TransientDataSession SqlTypes Mapping Documents Controls Animation System.Remoting Monitoring SignalingSession SqlXML ObjectSpaces Text Element Dialogs Controls System.Runtime.Remoting Logging Uddi Media OdbcClient ObjectSpace Shapes SideBar Control Relevance Activities OleDbClient Query Shape Notification Panel Navigation OracleClient Schema Ink Design System.Web.Services System.MessageBus Transport Queue Web.Service System.Storage Port PubSub System.Windows.Forms System.Web.UI Description Item Core Channel Router Forms Page WebControls Discovery Relationship Contact Service Policy Control Control Adaptors Protocols Media Location Peer Group Print Dialog HtmlControls Design Audio Message Design MobileControls Video Document System.Net System.Web Images Event HttpWebRequest NetworkInformation System.Help System.Speech Personalization System.Xml FtpWebListener Sockets System.Drawing Recognition Synthesis Caching Schema Xpath SslClientStream Cache SessionState System.NaturalLanguageServices Serialization Query WebClient Fundamentals Security Base & Application Services Configuration Deployment/Management System.Windows.TrustManagement System.Text System System.Web.Configuration System.Collections System.Web System.Security System.Globalization System.Design System.MessageBus.Configuration Generic Administration Permissions Authorization System.Web.Security System.Serialization System.IO System.Configuration Management System.ComponentModel Policy AccessControl Ports System.Threading System.Resources System.CodeDom Principal System.Management Credentials System.MessageBus.Security System.Runtime System.Reflection Token Cryptography System.Deployment Serialization InteropServices System.EnterpriseServices System.Diagnostics CompilerServices System.Transactions
Talk Focus • This talk is focused on • Features which enable you to be more productive (write your code more quickly) • Features which allow you to write faster, or more resource aware code • Features which YOU asked for! • (more managed solutions)
AgendaTopic Breakdown New Managed Solutions Productivity Ease-Of-Use Faster, Resource Aware Console RAD Debugging Generics SerialPort TryParse Strongly Typed Resources Tracing Memory Pressure Friend Assemblies Environment Threading EventLog IO
AgendaIncreased Productivity Increased Productivity, Ease-Of-Use Faster code-development by being simpler to use, and easier to find Console RAD Debugging Generics SerialPort TryParse Strongly Typed Resources Tracing Memory Pressure Friend Assemblies Environment Threading EventLog IO
Strongly-Typed Resources In this demo, we’ll see how working with resources has become even easier, with strongly-typed resources
Friend Assemblies AssemA AssemB Today, you have these options… class Foo {} class SubFoo : Foo {} class SomeClassA {} class SubFoo2 : Foo {} class SomeClassB {} AssemC class SomeClassC {} C# VB protected internal Internal protected private public ??? ??? Protected Friend Protected Friend Public Private/Dim How can AssemA make itself visible to everything in AssemB, but NOT AssemC?
Friend AssembliesUsing InternalsVisibleToAttribute AssemA Step 1 Apply the attribute [assembly:InternalsVisibleTo(“AssemB”, PublicKeyToken=”32ab4ba45e0a69a1”)] internal class Foo { public Foo() {} } AssemB// wants to access Foo Step 2 Reference the class! class Bar { Foo f = new Foo(); } Applies to assemblies only
AgendaFaster, Resource Aware Code Faster, Resource Aware code Code that runs faster, and more often Console RAD Debugging Generics SerialPort TryParse Strongly Typed Resources Tracing Memory Pressure Friend Assemblies Environment Threading EventLog IO
Generics Before Generics C# public class List { private object[] elements; private int count; public void Add(object element) { if (count == elements.Length) Resize(count * 2); elements[count++] = element; } public object this[int index] { get { return elements[index]; } set { elements[index] = value; } } public int Count { get { return count; } } } public class List<T> { private T[] elements; private int count; public void Add(Telement) { if (count == elements.Length) Resize(count * 2); elements[count++] = element; } public T this[int index] { get { return elements[index]; } set { elements[index] = value; } } public int Count { get { return count; } } } List intList = new List(); intList.Add(1); // Argument is boxed intList.Add(2); // Argument is boxed intList.Add("Three"); // Should be an error int i = (int)intList[0]; // Cast required List<int> intList = new List<int>(); intList.Add(1); // No boxing intList.Add(2); // No boxing intList.Add("Three"); // Compile-time error int i = intList[0]; // No cast required List intList = new List(); intList.Add(1); intList.Add(2); intList.Add("Three"); int i = (int)intList[0];
Generics In VB VB Public Class List(Of T) Private elements() As T Private elementcount As Integer Public Sub Add(ByVal element As T) If elementcount = elements.Length Then Resize(elementcount * 2) elements(elementcount) = element count += 1 End Sub Public Default Property Item(ByVal index As Integer) As T Get Return elements(index) End Get Set (ByVal Value As T) elements(index) = Value End Set End Property Public ReadOnly Property Count As Integer Get Return elementcount End Get End Property End Class Dim intList As New List(Of Integer) intList.Add(1) // No boxing intList.Add(2) // No boxing intList.Add("Three") // Compile-time error Dim i As Integer = intList(0) // No cast required
Generics In C++ C++ generic<typename T> public ref class List { array<T>^ elements; int count; public: void Add(T element) { if (count == elements->Length) Resize(count * 2); elements[count++] = element; } property T default [int index] { T get() { return elements[index]; } void set(T value) { elements[index] = value; } } property int Count { int get() { return count; } } }; List<int>^ intList = gcnewList<int>(); intList->Add(1); // No boxing intList->Add(2); // No boxing intList->Add("Three"); // Compile-time error int i = intList[0]; // No cast required
Enhancing The Base LibraryGeneric Collections • System.Collections.Generic classes • List<ItemType> • Dictionary<K,V> • Stack<ItemType> • Queue<ItemType> • System.Collections.Generic interfaces • IList<ItemType> • IDictionary<K,V> • ICollection<ItemType> • IEnumerable<ItemType> • IEnumerator<ItemType> • IComparable<OperandType> • IComparer<OperandType>
Enhancing The Base LibraryOther Generics to look out for • Nullable<T> • Extremely useful for situations where null is a value, such as database valuetypes Nullable<int> intVal = Nullable<int>.default; intVal = 5; // implicit cast from int int i = (int)intVal; // explicit cast to int if (intVal.HasValue) { // checks for a value • EventHandler<T> • Saves on making your own EventHandlers delegate voidEventHandler<T>(Object sender, T e) where T : EventArgs;
Enhancing The Base LibraryOther Generics to look out for • IComparable<T> • No boxing of valuetypes on comparison/sorting • No chance of passing in an invalid type public classDemoString : IComparable<string> { public int CompareTo(string other) ; public bool Equals(string other); } • ArraySegment<T> • Allows you to easily specify a subsection of an array • Supports cleaner API design Constructor: public ArraySegment(T[] array, int offset, int count); Old API: public void Send ( byte[], int, int ); New API: public void Send ( ArraySegment<byte> );
Speeding Things Up: Parsing Values In this demo, we'll see how TryParse can save you precious milliseconds, when comparing it to the traditional Parse routines
ThreadingSemaphore • Resource counting for mutex’s // construct a semaphore with a count of 2 Semaphore sem = new Semaphore(2); private void UseResource { // Wait until a count is available… sem.WaitOne(); // the sem count is reduced by one // other code … // Release the count: sem.Release(); // the count is incremented by one
AgendaNew Managed Solutions New Managed Solutions Managed solutions which weren’t available in V2003 Console RAD Debugging Generics SerialPort TryParse Strongly Typed Resources Tracing Memory Pressure Friend Assemblies Environment Threading EventLog IO
Console: Additional Features In this demo, we’ll see additional Console features making the Console a more robust experience
Others… • New String APIs, to make tasks easier, and make the most appropriate code easier • Remove( startIndex ) • Contains ( someString ) • Split ( char(), omitEmptyEntries ) • IO ACLs • Named Events in Threading • Timing out streams • IO: Decompression support • Transactions • RegularExpressions: character class subtraction • Performant scenarios for resources
Summary • Features have been introduced to provide: • An easier, better programming experience • Faster, more resource aware code • More managed solutions • Focus has been on evolution, not revolution Keep those requests coming!
Designer Features • More in-situ design experience, reduce obligatory visits to • the property grid • toolbars • menus • Streamline common tasks • reduce clicks • reduce amount of code necessary
Feature List • Snaplines • Smart tags • New selection UI / Semi-transparent dragging • In-situ string property editing • Document Outline • Toolbox improvements • Control Position / Size in Statusbar • Runtime Features • Visual Styles • GDI Text
Snaplines • Replaces grid layout mode • In-situ alignment (natural extension of IDE toolbar items “Align Tops”, etc.) • Like snaps to like (e.g. left border to left, etc.), exposes margins/padding • Controls can expose “interesting points” • TextBox and Label “baseline” snapline
Snaplines (cont) • New features: • Respects the new padding and margin properties on controls • These values will be set to Windows UI style guidelines • Works for resize operations • Supports multiselection • Initial control creation
In-Situ String Editing • Ability to edit a single property for all controls at once. • Similar to tab order editor in v1.1 • Only works for string properties
Smart Tasks • In-situ tasks, immediate • Extensible by 3rd parties
New Selection UI • Reduced number of handles • Reduced size of UI • Rounded to look good with visual styles • ... but still tweaking ...
Dragging UI Improvements • Real-time control rendering -- WYSIWYG • Semi-transparent
Document Outline View • Not just for HTML anymore! • Allows easy control navigation, Z-order modification, parenting
Toolbox Improvements • Auto-population • Informative tooltips • Search/filter
Visual Styles • Visual styles just work and are on by default • Setting the FlatStyle property is no longer necessary • Manifest is no longer necessary • VS and the design experience will support visual styles • Visual Style APIs • High level control based API for common drawing operations • Low level theme API for drawing theme parts • Low level API will be strongly typed for the beta • Works in semi trust
GDI Text Rendering • GDI+ text is resolution independent • It doesn’t look like GDI text • GDI text benefits from 10+ years of hardware acceleration • GDI text has better globalization character set support on XP and above