Docstoc

Overview of .NET Framework

Document Sample
Overview of .NET Framework Powered By Docstoc
					Overview of .NET Framework
What will we learn today
 .NET Evolution


 .NET Platform


 .NET Framework Architecture


 Basics of .Net Framework Library


 Summary
.NET Evolution
The .NET Evolution

     Application


       Code and
          data
       structures



        Before COM, applications were
        completely separate entities with
        little or no integration
The .NET Evolution




          COM provides a way for
          components to integrate.
          However, each component
          must provide the “plumbing”
          and objects cannot directly
          interact.
The .NET Evolution




      With the .NET Framework
      common language runtime,
      components are built on a
      common substrate. No
      “plumbing” is needed and
      objects can directly interact
.NET Platform
                        What is .NET?
   A platform
     The .NET Framework

       Visual Studio.NET

       .NET Enterprise Servers
           Database, Messaging, Integration, Commerce, Proxy, Security,
            Mobility, Orchestration, Content Management

       .NET Building Block Services
           Passport

       Goal: make it incredibly easy to build powerful Web
        applications and Web services
    .Net Framework Design Goals

          Simplify development
             More power, less plumbing
      Unify programming models
      Across all languages and application types
Utilize web standards and best practices
       Rich XML, standard protocols, stateless
   Easier to deploy, run, & maintain
       For components, versioning, availability
Benefits of .NET Framework
.NET Framework Architecture
        .NET Framework Architecture
VB     C++    C#    JScript    …

 Common Language Specification




                                      Visual Studio.NET
ASP.NET: Web Services    Windows
   and Web Forms          Forms

      ADO.NET: Data and XML

        Base Class Library

     Common Language Runtime
        .NET Framework Architecture

VB     C++    C#    JScript    …

 Common Language Specification




                                      Visual Studio.NET
ASP.NET: Web Services    Windows
   and Web Forms          Forms

      ADO.NET: Data and XML

        Base Class Library

     Common Language Runtime
Common Language Runtime - Overview

 Highlights
    Common type system
        Mapping of data types. Programming language  Framework

    Just-in-time (JIT) compilers
        JIT compiles intermediary language (MSIL) into native code
        Highly optimized for platform or device

    Garbage collector


    Permission and policy-based security


    Exceptions


    Threading


    Diagnostics and profiling
Common Language Runtime
Diagram Base Class Library Support
      Thread Support              COM Marshaler

       Type Checker            Exception Manager

      Security Engine             Debug Engine

  MSIL to Native         Code           Garbage
  Compilers (JIT)       Manager       Collector (GC)

                      Class Loader
        .NET Framework Architecture
VB     C++    C#    JScript    …

 Common Language Specification




                                      Visual Studio.NET
ASP.NET: Web Services    Windows
   and Web Forms          Forms

      ADO.NET: Data and XML

        Base Class Library

     Common Language Runtime
          .NET Framework - Overview
                A Unified Programming Model
               Consistent API availability regardless of
                 language and programming model

                           .NET Framework




                           Subclassing,                        Stateless,
   RAD,
                              Power,                       Code embedded
Composition,
                          Expressiveness                    in HTML pages
 Delegation

 VB Forms                     MFC/ATL                           ASP




                              Windows API
                   Things become 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();
               Web Standards/Practices

• The .NET Framework supports
   –    HTML, XML, SOAP, XSLT, XPath
•Web services enables internet scale distributed apps
   –    State-full connected model does not work
   –     Loosely connected web services enables scalable apps
•XML support is built in deeply
  -    Data, remoting, serialization, documentation, config
        .NET Framework Architecture

VB     C++    C#    JScript    …

 Common Language Specification




                                      Visual Studio.NET
ASP.NET: Web Services    Windows
   and Web Forms          Forms

      ADO.NET: Data and XML

        Base Class Library

     Common Language Runtime
 Common Language
 Specification languages compiled into MSIL
 All .NET programming
 (Microsoft Intermediate Language)

 The Common Language Specification (CLS) is a set of
 rules that a language compiler has to adhere to, in order
 to create .NET programs that can run on CLR.
        .NET Framework Architecture

VB     C++    C#    JScript    …

 Common Language Specification




                                      Visual Studio.NET
ASP.NET: Web Services    Windows
   and Web Forms          Forms

      ADO.NET: Data and XML

        Base Class Library

     Common Language Runtime
   Types of Supported Languages


 Object Oriented


 Procedural


 Functional


 Common Language Specification


 Same Tool can be used for all languages
.NET Core Languages

   C++
     Attribute based programming
     Managed Extensions for C++


   C#
     Modern, object oriented, type-safe language
     Bringing RAD to the C++ developer


   Visual Basic.Net
     Object oriented language provides code reusability
     Maximum scalability with Free Threading
     Easier maintainability with Structured Exception Handling
    Third Party Languages
   Perl – http://www.activestate.com/.net
   Python – http://www.activestate.com/.net
   Cobol – http://www.adtools.com/info/whitepaper/net.html
   Pascal – http://www.plasrc.qut.edu.au/ComponentPascal
   Eiffel – http://www.eiffel.com/doc/comtech
   Haskell – http://haskell.cs.yale.edu/ghc
   Mercury – http://www.cs.mu.oz.au/research/mercury
   APL – http://www.dyadic.com
   Scheme – http://rover.cs.nwu.edu/~scheme
   SmallTalk – http://www.qks.com
   Oberon – http://www.oberon.ethz.ch/lightning
   Standard ML – http://research.microsoft.com/Projects/SML.NET
        .NET Framework Architecture

VB     C++    C#    JScript    …

 Common Language Specification




                                      Visual Studio.NET
ASP.NET: Web Services    Windows
   and Web Forms          Forms

      ADO.NET: Data and XML

        Base Class Library

     Common Language Runtime
Visual Studio® .NET
The complete development environment for building distributed applications for Windows®
and the Web

                                                 Most productive tool for creating
                                                  and consuming Web services
        Visual Studio .NET
                                                 Open, extensible development
                                                  environment
            .NET Framework
                                                 High productivity tools for team-
                                                  based enterprise Web
              Windows                             development
         Application Services
                                                 End-to-end tools for enterprise
      Communication Protocols                     lifecycle productivity
      XML, SOAP, HTTP, HTML
Common Language Runtime
       In Details
                          Common Language Runtime

                                            Frameworks

                                             Base Classes
Common Language Runtime




                           native code




                                                   Execution
                            compilers




                                                                   Security
                                                    Support
                               IL to




                                 GC, stack walk, code manager
                                         Class loader and layout
    Common Language Runtime


       Manages running code
                Verifies type safety
     Provides garbage collection, error handling
     Code access security for semi-trusted code

  Provides common type system
    Value types (integer, float, user defined, etc)
                 Objects, Interfaces

Provides access to system resources
            Native API, COM interop, etc.
  Services of the CLR



 Memory Management
 Threads
 Garbage collection
 Exception handling
 Security
 Application Isolation
 Data Interaction
 Encryption Services
 Deployment
One Runtime For All Languages



 CLR is an open standard
 Any language can make use of CLR services
 Any language can use classes written in any other
  language (consumer)
 Any language can (code) inherit classes written in any
  other language (extender)
 A language can become a provider
                 CLR Execution Model
Source      VB              C#             C++
code
                                                    Unmanaged
          Compiler       Compiler        Compiler
                                                    Component

Managed   Assembly       Assembly        Assembly
code       IL Code        IL Code         IL Code



   Common Language Runtime

                      JIT Compiler


                           Native Code


                     Operating System Services
CLR Simplifies Development
Completely eliminates COM plumbing
             No more…
             Registration
                =>self describing components
              GUIDs
                =>hierarchical namespaces
            .IDL files
                 =>source code to metadata

             HRESULTs
                =>structured exceptions
             IUnknown
                =>root object class
             AddRef/Release
                =>garbage collector
                     Garbage Collection

       Process of automatically freeing up memory when an
        object it been allocated to is no longer being used

       Prevents the following errors:
         Forgetting to destroy objects
         Attempting to destroy the same object more than once
         Destroying an active object
Anatomy of .NET applications
                         Assembly
                             Manifest


                             Module

                         Metadata


                               IL

               Type                 Type
               •Methods             •Methods
               •Properties          •Properties
               •Fields              •Fields
                       Assemblies


ParcelTracker.DLL   myAssembly.DLL                Util.DLL

   Metadata         Assembly Metadata          Type Metadata
    IL/native         Type Metadata               IL Code
      code
                         IL Code
   Resources
                                                Graphic.BMP
                                                 Resources
 Single Module
                                   Multiple Modules
    Intermediate Language (IL)
     Assembly Language of CLR
     Code is never interpreted



  VC                              Standard JIT
                                    Compiler

  VB
                                                 Native
                       IL
                                                 Code
  ...
                                  “Econo”-JIT
                                   Compiler
Script
  Managed vs. Unmanaged


 Managed Code makes use of CLR services
 Unmanaged Code does not use any services
 Garbage Collector can be turned off
 CLR offers mechanisms for managed code to interact
  with unmanaged code
 Interoperation with hardware specific code and other
  platforms
 Ability to reuse old code
Runtime Control Flow
                           Class
                          Loader
                                       First
                                       reference to
                        IL to native   type
                       code compiler
          Execution
           Support
                         Managed       First call to
           Code           Native       method
          Managers        Code


           Security
                           CPU
           System
  Verification
 IL is verified by a verifier and guaranteed to be type safe

 Checks for type casts, memory initialization, array
  bounds

 Checks stack operations
  Versioning

 Multiple versions of component can be installed on
 machine

 A single process can use different version of component
 at same time

 Zero-impact installation and uninstallation (copy)
.NET Framework Components
        in Details
 .NET Framework Namespaces


ASP.NET              Windows


ADO.NET                  XML


    Base Class Library
             System.Web                                   System.Windows.Forms

  Services                 UI                    Design            ComponentModel
 Description          HtmlControls
 Discovery            WebControls
 Protocols                                                   System.Drawing

 Caching                   Security               Drawing2D                 Printing
Configuration         SessionState                  Imaging                   Text

             System.Data                                       System.Xml

    ADO                     SQL                      XSLT               Serialization
   Design              SQLTypes                      XPath

                                        System

 Collections                  IO                 Security                Runtime
Configuration                 Net            ServiceProcess          InteropServices

 Diagnostics               Reflection              Text                 Remoting

Globalization              Resources             Threading            Serialization
Windows Forms
Windows Forms

 Rich, powerful client UI
    Control anchoring, visual inheritance
    Shared across all .NET languages


 Secure
    Fully-trusted local application


 Full Web Service integration
.Net Framework Library
    Looking Back


   Language Dependent Runtime Libraries
        C-Runtime library
        C++ Standard Template Library
        Visual Basic Runtime
            API holes plugged with ActiveX controls

   Discriminatory access to functionality
        Many APIs unsupported by Visual Basic
        Advanced tasks often require C/C++
   Core functionality scattered all over Windows
        ActiveX controls, System DLLs, SDKs, IE
    The .NET Framework Library


   One-stop, well-organized class framework
        OS-independent subset submitted to ECMA
            Standardization backed by Microsoft, HP, Intel
        Subset includes most things covered here
        http://msdn.microsoft.com/net/ecma
   Integrates all current Windows technologies
        Everything in one place – for all languages
        Windows Forms, GDI+, Printing for Windows Dev
        Web Forms, Web Services, Networking for Net Dev
        Supports Active Directory, WMI, MSMQ, Services
 The System Namespace
 System.Object


 The not-so-primitive "primitive" types


 String and text classes


 Dates, times and calendars


 System console support
 The Root of Everything: System. Object


 Base class for each and every type
    Inheritance from System.Object is typically implicit
    All simple and complex types share the same base
 Single base-class makes framework consistent
    Collection classes can be used for everything
    Intrinsic model for handling variant types
    Strongly typed. No pointers, no structures
        Much less error prone than COM's VARIANT type
 System.Object is a reference type
 Value types (internally) inherit from ValueType
    Special class derived from Object
 System. Object’s Methods (1/2)
 bool System.Object.Equals(Object o)
    Reference identity for reference types (default)
    Overridden for value types to test value identity
 void System.Object.Finalize()
    To be overridden by subclasses
    Called when object is garbage collected
 int System.Object.GetHashCode()
    i.e. used with System.Collections.HashTable
    Should be overriden to return good hashes
        Good hash distribution speeds up hash tables
    Default implementation: Identity-based hash
 System. Object’s Methods (2/2)


 System.Type System.Object.GetType()
    Retrieves the type object for the object's class
    GetType() is the entry point for .NET Reflection
 System.Object System.Object.MemberwiseClone()
    Creates a exact clone of "this" object
    Works through Reflection with any class
 System.String ToString()
    To be overriden; Returns text representation
    Default returns qualified name of "this" class
    Not designed for user messages (use IFormattable)
 The “Primitive” Types


 Traditionally perceived as "magic" or "special"
    There is no primitive-type magic-ness in .NET!
    Very SmallTalk-like model
    "Primitive" types are regular framework types
 However, still exposed as language-intrinsic types
    C#: bool, int, long, string, double, float
    Visual Basic.NET: Boolean, Integer, String
 "Primitives" are mostly value-types
    Exception: System.String is reference type
 "Primitive" Types are not so primitive anymore
    Full featured classes, rich functionality
 System. String


 System.String is the cross-language string
    One storage method, one API, unified handling
    Locale-aware, always Unicode
 Fully-featured string handling capabilities
    Forward and reverse substring searches
        IndexOf(), LastIndexOf(), StartsWith(), EndsWith()
    Whitespace stripping and padding
      Trim(), PadLeft(), PadRight()
    Range manipulation and extraction
      Insert(), Remove(), Replace(), Substring(), Join(), Split()
    Character casing and advanced formatting
      ToLower(), ToUpper() and
      Format() much like C's printf but safe
 System. Text


 StringBuilder
    Super-efficient for assembling large strings


 Encoders and Decoders
    Support character encoding and conversions


    ASCII, UTF-8, UTF-7, Windows Codepages


    Unicode encoder for full UTF-16 compliant streams
      Encoder can write and decoder detect byte-order marks
      Supports big-endian and little-endian Unicode encoding
 Date and Time Support


 System.DateTime class for dates and times
    Virtually unlimited date values (100 AD to 9999 AD)
    Date and Time arithmetics built-in
        AddDays(), AddSeconds()
    Sophisticated, locale-aware formatting and parsing
 System.TimeSpan for durations
    Can represent arbitrary timespans
    Can express span in arbitary units by conversion
 System.TimeZone for time-zone support
 The Console


 System.Console class for console I/O
 Supports standard in, standard out, standard error
 Writing to the console
   Write() or WriteLine()
   Supports String.Format syntax
        Console.Write("Snowwhite and the {0} dwarfs", 7)
 Reading from the console
    Read() reads on characters
    ReadLine() reads one full line
 Other System Goodies


 System.URI class
    Two-way parsing and construction of URIs


 System.Random class
    Random number generator


 System.Radix class
    Numeric base-system conversions (eg. Dec/Hex)


 System.Convert class
    One-stop place for core type conversions
References:

• Introduction to .NET(Wrox Publication)
• http://www.msdn.microsoft.com/net
• http://gotdotnet.com

				
DOCUMENT INFO
Shared By:
Stats:
views:57
posted:8/15/2010
language:English
pages:62