Introduction to .NET Framework - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to .NET Framework

Description:

Introduction to .NET Framework Gholamali Semsarzadeh July 2001 What Is .NET .Net is a new framework for developing windows-based and web-based applications within the ... – PowerPoint PPT presentation

Number of Views:39
Avg rating:3.0/5.0
Slides: 27
Provided by: csUcyAcC
Category:

less

Transcript and Presenter's Notes

Title: Introduction to .NET Framework


1
  • Introduction to .NET Framework
  • Gholamali Semsarzadeh
  • July 2001

2
What Is .NET
  • .Net is a new framework for developing
    windows-based and web-based applications within
    the Microsoft environment.
  • The framework offers a new set of software
    development tools that are superior to the old
    tools.
  • The framework offers a fundamental shift in
    Microsoft strategy it moves application
    development from client-centric to
    server-centric.

3
Agenda
  • Common language runtime (CLR)
  • .NET class library
  • Cross language application development
  • Tools for developing Windows applications
  • Tools for developing Web applications

4
Common Language Runtime (CLR)
  • CLR works like a virtual machine in executing all
    languages. Currently it supports two
  • C is the new version of C containing all
    features of Java.
  • VB.NET is the new version of VB containing full
    object orientation and equal in power to C.
  • All .NET languages must obey the rules and
    standards imposed by CLR. Examples
  • Object declaration, creation and use
  • Data types,language libraries
  • Error and exception handling
  • Interactive Development Environment (IDE)

5
Intermediate Language (IL)
  • .NET languages are not compiled to machine code.
    They are compiled to an Intermediate Language
    (IL).
  • CLR accepts the IL code and recompiles it to
    machine code. The recompilation is just-in-time
    (JIT) meaning it is done as soon as a function or
    subroutine is called.
  • The JIT code stays in memory for subsequent
    calls. In cases where there is not enough memory
    it is discarded thus making JIT process
    interpretive.

6
Common Data Types
  • CLR provides a set of primitive types that all
    languages must support. The data types include
  • Integerthree types 16/32/64 bits
  • Floattwo types 32/64 bits
  • Boolean and Character
  • Date/time and Time span
  • The primitive types can be collected into
  • Arrays
  • Structures
  • Combination of the two

7
Common Type System
  • IL is completely object-oriented. It requires
    everything to be the type of a class, structure
    or interface.
  • Examples of types
  • Integer
  • String
  • Rectangle
  • Customer
  • Contract
  • Chart
  • Recordset
  • Check
  • Financial Institution

8
Examples of Types
9
Metadata
  • A type must be self descriptive It must
    describe properties and methods that it exposes.
  • Examples
  • The type Integer describes what values it takes
    and what operations it accepts.
  • The type Check describes what values (e.g.,
    AccountNo and Amount) it takes and what
    operations (e.g., Cash, Deposit) it accepts.
  • The Metadata is an integral part of an executable
    such as CHART.DLL. The DLL describes two things
    about the Chart type what it does and how it
    does it.

10
Assembly
  • To allow others to use a type, the developer must
    package it in an assembly.
  • A component (delivered in an assembly) is the
    building block for software construction.
  • Structurally an assembly consists of a manifest
    and one or more modules. Each module consists of
    metadata (in IDL) and one or more types (in IL).

11
Manifest
  • The manifest identifies an assembly and declares
    its contents.
  • It describes
  • Identity of an assembly
  • Its security requirements
  • The identity of other assemblies it depends on
  • The types exposed by the assembly

12
.NET Class Library
  • In traditional environments different categories
    of services are provided to the programmer via
    libraries such as C run time library, Win32
    APIs, I/O and database access libraries,
    statistical libraries, etc.
  • These libraries are language dependent, operating
    system dependent, and often contain simple
    subroutine calls as opposed to self describing
    types.
  • In .NET all services fall into a single,
    hierarchy organized, language independent Class
    Library.

13
.NET Class Library 2
  • The organization of the Class Library is similar
    to the file system
  • Each folder is a NameSpace
  • Each file is an assembly exposing one or more
    types
  • The root of the Class Library is the System
    NameSpace
  • The Class Library contains 25 second level
    NameSpaces such as Data, I/O, WinForms, Security,
    etc. that contain thousands of types exposing all
    services of the operating system.
  • All components developed by the users or vendors
    must be added to the Class Library before they
    can be used.

14
VB.NET
  • The .NET version of Visual Basic is as powerful
    as C and is incompatible with its previous
    version VB 6.0.
  • It contains the following new features all of
    which are enforced by CLR and are common with C
  • Common IDE (Interactive Development Environment)
  • Common type system
  • Common object orientation capabilities
  • Common language library
  • Common error and exception handling
  • Common form drawing tools
  • Common Web page design tools

15
The OBJECT Class
  • OBJECT is the type from which all other types are
    derived.
  • The properties and methods that are shared by all
    objects are constructed in the OBJECT class.
    They include
  • Equals
  • GetType
  • Clone (duplicate)
  • GetHashCode
  • ToString
  • The OBJECT type in VB.NET replaces the VARIANT
    type in previous versions of VB.

16
Visual Basic Form as a Class
  • All .NET languages use the same tools (WinForms)
    to create the user interface of an application as
    a form.
  • A form a class containing other classes (called
    controls) such as TextBox, ListBox or Button.
  • The act of drawing a form (such as Form1)
    generates the VB.NET code that defines the
    corresponding class named Form1.
  • As a class, Form1 has methods, properties, and
    events. Examples
  • Form1.Show is a method that displays the Form1 on
    the screen.
  • Form1.EmpName.Text references the contents of the
    TextBox EmpName in Form1.
  • EmpName_Change is the name of the event handler
    that is invoked when the user changes contents of
    EmpName TextBox.

17
Inheritance Hierarchy of a Form
  • The following hierarchy shows how the Visual
    Basic Form Class is derived from the Object
    class.
  • Object The base class for everything
  • RefObject Objects called by reference
  • Component RefObjects that can be reused
  • Control components with visual interface
  • RichControl controls with advanced visual
    presentation such as color, font, docking
    capability
  • ScrollableControl controls that can be scrolled
  • ContainerControl Controls that can hold other
    controls and change focus among them
  • Form Base Form class from which application
    specific forms are derived

18
Inheriting From User Forms
  • The class Form is located in the NameSpace
    System.WinForms.
  • The act of drawing a form (Form1) in the IDE
    generates VB code containing the following
    declarations
  • Imports System.WinForms
  • Public Class Form1 Inherits Form
  • The user then adds additional controls and code
    to Form1. Form1 can now be used as the base
    class for Form2 using the following declaration
  • Imports System.WinForms
  • Public Class Form2 Inherits Form1

19
Visual Basic and WebForms
  • In a manner similar to drawing a WinForm, the VB
    programmer can now draw a WebForm (I.e., a Web
    Page)and attach event handlers to it.
  • WinForm controls such as Text, Image, and Anchor
    are similar to WinForm controls.
  • A Web page, just like a form, is a class with its
    own methods, properties and events. It can be
    inherited by other Web pages.
  • VB can thus be used to develop Web-based
    applications.

20
Visual Basic and Web Services
  • A Web Service a class (running on a Web Server)
    whose one or more methods are designated as
    WebMethods.
  • A WebMethod can be called from any client across
    the Internet.
  • The protocol for exchange of information is
    called SOAP (Simple Object Activation Protocol).
    It wraps the calling sequence in XML, invokes the
    remotely located method, and returns the computed
    results in XML.
  • DCOM distributes logic over tightly connected
    nodes on a LAN. SOAP distributes logic over
    nodes that are loosely connected across the
    Internet.

21
Web Applications in .NET
  • The central question in creation of Web pages is
    weather an HTML markup is instruction or data
  • lthtmlgtltbodygt
  • ltpgtThis is some text.lt/pgt
  • lt/bodygtlt/htmlgt
  • The perspective varies depending on whether or
    not we are using
  • HTML or DHTML to respond to user inputs
  • ASP (or JSP) to generate HTML markups
  • No matter how the Web page is generated the code
    behind it is very ad-hoc and non-structured. In
    the .NET platform, ASP.NET attempts to solve some
    of these problems.

22
Server-Side Controls
  • ASP and JSP provide a language to generate HTML
    markups. In ASP.NET the complexity of this
    language is significantly reduced by using
    server-side controls.
  • For each HTML control (such as a list box or an
    input text box) there exists a server-side
    control in ASP.NET. When a Browser requests a
    specific ASP.NET page in its URL the following
    events happen
  • The ASP.NET program is executed
  • Each server-side control in that program
    generates a corresponding HTML control
  • As the final result, the ASP.NET program
    generates an HTML page that is targeted to the
    version of the Browser that requested the page.

23
ExampleServer-Side Controls
  • ASP.NET code for displaying a listbox
  • ltASPListBox IDList1 RUNATServergt
  • ltASPListItemgtJanlt/ASPListItemgt
  • ltASPListItemgtFeblt/ASPListItemgt
  • ltASPListItemgtMarlt/ASPListItemgt
  • lt/ASPListBoxgt
  • Corresponding HTML code
  • ltSELECT Size3gt
  • ltOptiongtJanlt/Optiongt
  • ltOptiongtFeblt/Optiongt
  • ltOptiongtMarlt/Optiongt
  • lt/SELECTgt

24
Server-Side Processing
  • A server-side control can detect a user event
    (e.g., a mouse click) and execute a server-side
    script that contains the code (the event handler)
    to handle that event.
  • The event is generated on the client-side but
    handled on the server-side.
  • The event handler typically changes the
    properties and calls the methods of various
    controls on the ASP.NET page.
  • At the termination of the event handler a new
    HTML page is posted back to the Browser.

25
Example Server-Side Processing
  • lt_at_ import Namespacesystem.data gt
  • lt_at_ import Namespacesystem.data.SQL gt
  • lthtmlgt
  • ltheadgtltScript LANGUAGEVB, RUNATServer gt
  • Sub Page-load( )
  • Dim SqlCmd As NEW SQLDataSetCOmmand (
  • ServerlocalhostdatabaseBooks,
  • select from Authors )
  • Dim ds As New DataSet
  • SqlCmd.FillDataSet(ds, Authors)
  • Grid1.DataSourceds.Tables(Authors).Defaul
    tView
  • Grid1.DataBind
  • End Sub
  • lt/Scriptgt
  • lt/headgt
  • ltbodygt
  • ltASPDataGrid IDGrid1 RUNATServer /gt
  • lt/bodygtlt/htmlgt

26
ASP.NET Benefits
  • ASP.NET Uses .NET languages to generate HTML
    pages. HTML page is targeted to the capabilities
    of the requesting Browser
  • ASP.NET Program is compiled into a .NET class
    and cached the first time it is called. All
    subsequent calls use the cached version.
  • ASP.NET programs are developed using the same
    IDE tools as VB Programs. There are however two
    important differences
  • The code behind the controls is executed on the
    server
  • The Web application does not need the CLR or the
    .NET Class Library to executeany Browser will do.
Write a Comment
User Comments (0)
About PowerShow.com