1 / 26

Introduction to .NET Framework Gholamali Semsarzadeh July 2001

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 Microsoft environment. The framework offers a new set of software development tools that are superior to the old tools.

ceallach
Download Presentation

Introduction to .NET Framework Gholamali Semsarzadeh July 2001

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. Introduction to .NET Framework • Gholamali Semsarzadeh • July 2001 Introduction to .NET

  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. Introduction to .NET

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

  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) Introduction to .NET

  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. Introduction to .NET

  6. Common Data Types CLR provides a set of primitive types that all languages must support. The data types include: • Integer—three types 16/32/64 bits • Float—two 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 Introduction to .NET

  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 Introduction to .NET

  8. Examples of Types Introduction to .NET

  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. Introduction to .NET

  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). Introduction to .NET

  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 Introduction to .NET

  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. Introduction to .NET

  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. Introduction to .NET

  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 Introduction to .NET

  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. Introduction to .NET

  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. Introduction to .NET

  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 Introduction to .NET

  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 Introduction to .NET

  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. Introduction to .NET

  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. Introduction to .NET

  21. Web Applications in .NET • The central question in creation of Web pages is weather an HTML markup is instruction or data: <html><body> <p>This is some text.</p> </body></html> • 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. Introduction to .NET

  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. Introduction to .NET

  23. Example:Server-Side Controls • ASP.NET code for displaying a listbox: • <ASP:ListBox ID=“List1” RUNAT=“Server”> • <ASP:ListItem>Jan</ASP:ListItem> • <ASP:ListItem>Feb</ASP:ListItem> • <ASP:ListItem>Mar</ASP:ListItem> • </ASP:ListBox> • Corresponding HTML code: • <SELECT Size=3> • <Option>Jan</Option> • <Option>Feb</Option> • <Option>Mar</Option> • </SELECT> Introduction to .NET

  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. Introduction to .NET

  25. Example: Server-Side Processing • <%@ import Namespace=“system.data” %> • <%@ import Namespace=“system.data.SQL” %> • <html> • <head><Script LANGUAGE=“VB”, RUNAT=”Server” > • Sub Page-load( … ) • Dim SqlCmd As NEW SQLDataSetCOmmand ( • “Server=localhost;database=Books”, • “select * from Authors” ) • Dim ds As New DataSet • SqlCmd.FillDataSet(ds, “Authors”) • Grid1.DataSource=ds.Tables(“Authors”).DefaultView • Grid1.DataBind • End Sub • </Script> • </head> • <body> • <ASP:DataGrid ID=“Grid1” RUNAT=“Server” /> • </body></html> Introduction to .NET

  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 execute—any Browser will do. Introduction to .NET

More Related