1 / 45

.Net Framework

.Net Framework. Joel Pereira (joelcdp@microsoft.com) Software Design Engineer WinFS API Team Microsoft Corporation. Agenda. Part I - Fundamentals Programming Models Design Goals and Architecture CLR Services Part II – Visual Studio 2005 Extending the Platform Improving the Platform

jaden
Télécharger la présentation

.Net Framework

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. .Net Framework Joel Pereira (joelcdp@microsoft.com) Software Design Engineer WinFS API Team Microsoft Corporation

  2. Agenda • Part I - Fundamentals • Programming Models • Design Goals and Architecture • CLR Services • Part II – Visual Studio 2005 • Extending the Platform • Improving the Platform • Innovation in the Platform

  3. Consistent API availability regardless of language and programming model .NET Framework RAD, Composition, Delegation Subclassing, Power, Expressiveness Stateless, Code embedded in HTML pages ASP VB Forms MFC/ATL Windows API Unify Programming Models

  4. Make It Simple To Use • Organization • Code organized in hierarchical namespaces and classes • Unified type system • Everything is an object, no variants, one string type, all character data is Unicode • Component Oriented • Properties, methods, events, and attributes are first class constructs • Design-time functionality

  5. How Much Simpler? Windows API HWND hwndMain = CreateWindowEx( 0, "MainWClass", "Main Window", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND)NULL, (HMENU)NULL, hInstance, NULL); ShowWindow(hwndMain, SW_SHOWDEFAULT); UpdateWindow(hwndMain); .NET Framework Form form = new Form(); form.Text = "Main Window"; form.Show();

  6. Hello World Demo • What you need

  7. Agenda • Part I - Fundamentals • Programming Models • Design Goals and Architecture • CLR Services • Part II – Visual Studio 2005 • Extending the Platform • Improving the Platform • Innovation in the Platform

  8. Common Language RuntimeDesign Goals • Dramatically simplifies development and deployment • Unifies programming models • Provides robust and secure execution environment • Supports multiple programming languages

  9. ExecutionSupport Security IL to native code compilers Architectural Overview Framework Base Classes Common Language Runtime GC, stack walk, code manager Class loader and layout

  10. Assembly Language Compiler Native Code JIT Compiler Execution Compilation And Execution Compilation Code (IL) Source Code Metadata At installation or the first time each method is called

  11. Languages • The CLR is Language Neutral • All languages are first class players • You can leverage your existing skills • Common Language Specification • Set of features guaranteed to be in all languages • We are providing • VB, C++, C#, J#, JScript • Third-parties are building • APL, COBOL, Pascal, Eiffel, Haskell, ML, Oberon, Perl, Python, Scheme, Smalltalk…

  12. Hello World Demo • What you need • MSIL

  13. Agenda • Part I - Fundamentals • Programming Models • Design Goals and Architecture • CLR Services • Part II – Visual Studio 2005 • Extending the Platform • Improving the Platform • Innovation in the Platform

  14. Component-Based Programming • 3 core technologies make building and using components easy • Type safety • Automatic memory management • Metadata • This greatly simplifies application development

  15. Type Safety • Type safety ensures that objects are used the way they were intended to be used • Prevents an object’s state from being corrupted • The CLR enforces type safety • Attempting to coerce an object to an incompatible type causes the CLR to throw an exception • Type safety means code confidence • Common programmer errors will be found immediately Rectangle(hwnd, 0, 0, 10, 10); //hwnd should be an hdc MessageBox(hwnd, “”, “”, IDOK); //IDOK should be MB_OK

  16. Automatic Memory Management • The CLR tracks the code’s use of objects and ensures • Objects are not freed while still in use (no memory corruption) • Objects are freed when no longer in use (no memory leaks) • Code is easier to write because there is no question as to which component is responsible to free an object • When passed a buffer, who frees it: caller or callee? • Each process has 1 heap used by all components • Objects can’t be allocated from different heaps • You don’t have to know which heap memory was allocated in or which API to call to free the memory • In fact, there is no API to free memory, the GC does it

  17. Metadata • Set of data tables embedded in an EXE/DLL • The tables describe what is defined in the file (Type, fields, methods, etc.) • Every component’s interface is described by metadata tables • A component’s implementation is described by Intermediate Language • The existence of metadata tables enables many features • No header files • Visual Studio’s IntelliSense • Components don’t have to be registered in the registry • Components don’t need separate IDL or TLB files • The GC knows when an object’s fields refer to other objects • An object’s fields can be automatically serialized/deserialized • At runtime, an application can determine what types are in a file and what members the type defines (also known as late binding) • Components can be written/used by different languages

  18. Metadata: Creation And Use Serialization Reflection Source Code TLB Exporter Designers Compiler Compilers Debugger Metadata (and code) Type Browser Profiler Proxy Generator Schema Generator XML encoding (SDL or SUDS)

  19. Runtime Execution Model ClassLoader Assembly First reference to type IL to nativeconversion AssemblyResolver First reference to Assembly ManagedNative Code First callto method CPU

  20. JIT Compiler - Inline

  21. Standardization • A subset of the .NET Framework and C# submitted to ECMA • ECMA and ISO International Standards • Co-sponsored with Intel, Hewlett-Packard • Common Language Infrastructure • Based on Common Language Runtime and Base Framework • Layered into increasing levels of functionality

  22. Rotor (SSCLI) • Shared-Source version of the CLR+BCL+C# compiler • Ports available: Windows, FreeBSD, OSX, etc • Real product code offers real world learning • http://sscli.org

  23. Developer Roadmap Visual Studio Orcas “Longhorn” Visual Studio 2005 “Yukon” • “Orcas” release • Windows “Longhorn” integration • New UI tools and designers • Extensive managed interfaces Visual Studio.NET 2003 • “Whidbey” release • SQL Server integration • Improved IDE productivity and community support • Extended support for XML Web services • Office programmability • “Everett Release” • Windows Server 2003 integration • Support for .NET Compact Framework and device development • Improved performance

  24. Agenda • Part I - Fundamentals • Design Goals • Architecture • CLR Services • Part II – Visual Studio 2005 • Extending the Platform • Improving the Platform • Innovation in the Platform

  25. SQL Server IntegrationDesign Goal • Bring framework programming model into the database tier • Allow business logic to easily migrate to the most appropriate tier • Enable safe database extensions • Result: Stored Procedures, Triggers, data types defined in managed code

  26. VB, C#, … Build Assembly: geom.dll SQL Data Definition: create assembly … create function … create procedure … create trigger … create type … SQL Server SQL Queries: SELECT name FROM Supplier WHERE Location.Distance ( @point ) < 3 SQL CLR Functionality VS .NET Project Define Location.Distance() CLR hosted by SQL (in-proc)

  27. Sql Programming Model Splitting a string T-SQL • The old way…. declare @str varchar(200) select @Str = 'Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-08-20|11:32:00|Document|3.b.3' SELECT substring(@Str + '|', 0 + 1, charindex('|', @Str + '|', 0 + 1) - 0 - 1 ), substring(@Str + '|', charindex('|', @Str + '|') + 1, charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - charindex('|', @Str + '|') - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - 1 ) declare @str varchar(200) select @Str = 'Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-08-20|11:32:00|Document|3.b.3' SELECT substring(@Str + '|', 0 + 1, charindex('|', @Str + '|', 0 + 1) - 0 - 1 ), substring(@Str + '|', charindex('|', @Str + '|') + 1, charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - charindex('|', @Str + '|') - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) - 1 ), substring(@Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1, charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) + 1) - charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|', charindex('|', @Str + '|') + 1) + 1) + 1) + 1) + 1) + 1) - 1 )

  28. Sql Programming Model Splitting a string VB The new way…. Public Shared Sub SplitString() Dim s As String s = "Microsoft Corporation|SQL Server|2003|SQL-CLR|2002-08- 20|11:32:00|Document|3.b.3" Dim myArray() As String = Split(s, "|") End Sub

  29. Moving to 64 bit • 64 bit for Servers and workstations • X64 and IA64 bit support • Enable Yukon and ASP.NET • Verifiable managed binaries just run! • VS: Runs as a 32bit application • You can develop, deploy, and debug 32 and 64bit applications

  30. Agenda • Part I - Fundamentals • Design Goals • Architecture • CLR Services • Part II – Visual Studio 2005 • Extending the Platform • Improving the Platform • Innovation in the Platform

  31. Performance Objectives: make .NET an even greater programming platform • Long-Term: make the performance characteristics of the CLR similar to native code • Reduce marginal cost of additional managed processes • Reduce startup time and working set NGen • Compiles IL code to native code, saving results to disk • Advantages: no need to recompile IL to native code, and class layout already set so better startup time • Whidbey: Significant reductions in the amount of private, non-shareable working set • OS: ‘no-Jit’ plan, all managed code will be NGened

  32. Performance everywhere New, Performant APIs • APIs for faster resource lookup • Lightweight CodeGen: only generates essential code (contrast to Reflect Emit) Existing APIs Improved • Cross AppDomain Remoting Between 1.1 and 200x faster. Biggest gains for simpler items (strings, integers, serializable objects) • Delegate invoke performance has more than doubled • AppDomain Footprints: significantly reduced • UTF8Encoding: translation is 2.5x faster

  33. TryParse

  34. RAD Debugging • Edit and Continue: Edit Code at runtime Allowed Edits: Examples • Add private fields to a class • Add private non-virtual methods to a class • Change a function body, even while stepping Disallowed Edits: Examples • Removing fields/methods • Edits to generic classes • Serialization will not recognize new fields • Display Attributes for a better debugging experience

  35. CLR Security • New cryptography support • PKI and PKCS7 support • XML encryption support • Enhanced support for X509 certificates • Enhanced Application Security • Permission Calculator • Integration with ClickOnce • Better SecurityException • Debug-In-Zone • Managed ACL Support

  36. Agenda • Part I - Fundamentals • Design Goals • Architecture • CLR Services • Part II – Visual Studio 2005 • Extending the Platform • Improving the Platform • Innovation in the Platform

  37. Generics • Why generics? • Compile-time type checking • Performance (no boxing, no downcasts) • Reduced code bloat (typed collections) • VB, C#, MC++ produce & consume generics • Usegenerics freely in internal APIs • Consider using generics in public APIs • Generics are not yet in CLS • To be CLS compliant, provide a non-generic API alternative • Microsoft is actively pursuing standardization of generics in runtime and languages

  38. Enhancing The Base LibraryOther Generics to look out for • Nullable(Of T) • Extremely useful for situations where null is a value, such as database valuetypes • EventHandler<T> • Saves on making your own EventHandlers Dim intVal as Nullable(Of Integer) = 5 If intVal.HasValue Then ‘ checks for a value delegate voidEventHandler<T>(Object sender, T e) where T : EventArgs;

  39. Whidbey Tracing Features Pluggable Formatters • Pre-Whidbey : Formatting of Trace information was predefined, and not controllable • Whidbey : Predefined formatters (delimiter, xml) added, and you can make your own MySource;Error;13;Wrong key;;;;;;318361290184; Additional Listeners • Pre-Whidbey : No Console listener, ASP had their own tracing mechanism • Whidbey : Added Console listener. Integrated ASP tracing into our own, and added ETW listener

  40. Whidbey Tracing Features Auto-generated Data • Pre-Whidbey : Standard information such as timestamp or callstack would have to be explicitly generated • Whidbey : An Admin can easily generate this data automatically, via config settings <listeners> <addname="examplelog" type= … Simple Thread Identification • Pre-Whidbey : specific threads were difficult to identify, and filter on • Whidbey : Correlation ID has been added, which allows quick and easy identification of a thread, and simple subsequent filtering

  41. Whidbey Tracing Features Listener Filtering • Pre-Whidbey : Formatting of Trace information was predefined, and not controllable • Whidbey : Assign filtering to listeners, so only certain messages are traced. This allows filtering on any property of a message. E.g., ID, TimeStamp, etc. Switches • Pre-Whidbey : Couldn’t determine what tracing a component supported • Whidbey : Support the ability to determine what tracing mechanisms a component has

  42. Attend a free chat or web cast http://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asp List of newsgroups http://communities2.microsoft.com/ communities/newsgroups/en-us/default.aspx MS Community Sites http://www.microsoft.com/communities/default.mspx Local User Groups http://www.msdnbrasil.com.br Community sites http://www.microsoft.com/communities/related/default.mspx

  43. Resources • BCL Blog http://weblogs.asp.net/bclteam • BCL Website http://www.gotdotnet.com/team/clr/bcl/default.aspx • BCL public mail alias bclpub@microsoft.com • Reference .NET Framework Standard Library Annotated Reference Applied Microsoft .Net Framework Programming

  44. Q & A:

  45. © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

More Related