.Net Overview

Tom Lathrop Al Arujunan

©Eastman Kodak Company, 2001

Outline

• Introduction • CLR • .Net Languages • Miscellaneous Topics • ASP.Net

©Eastman Kodak Company, 2001

1 Introduction

©Eastman Kodak Company, 2001

Introduction

• .Net – ’s next-generation architecture • Microsoft’s biggest new architectural initiative since Windows • Microsoft is spending ~ $2 billion/year on .Net

©Eastman Kodak Company, 2001

2 Goals of .Net

• Make it easier to build web-based applications • Simplify programming model – Particularly for ++ • Simpler, safer deployment – No more “DLL hell”

©Eastman Kodak Company, 2001

Goals of .Net

• Make it easier to mix different languages in the same system • Cross-platform deployment (within Windows family

©Eastman Kodak Company, 2001

3 The .NET Framework

• Designed from the ground up for a web services world • XML natively supported • Web service built in • Designed for high availability/reliability

©Eastman Kodak Company, 2001

.NET Platform Roadmap The .NET platform

End-User Your Application and Web Service Your Internal Clients Services

Orchestration Operations .NET Enterprise Servers .NET Applications Using Your Framework Service .NET Foundation Windows Services ME, 2000, XP, .NET Visual Internet Protocols Third Party Studio.NET SOAP, HTTP, SMTP, XML Web Services

©Eastman Kodak Company, 2001

4 .NET Framework Components • (CLR) – for all languages – Rich runtime environment • Rich class libraries – Base class libraries, ADO.Net and XML – for rich, Win32 applications • Web application platform ASP.NET – Rich interactive pages – Powerful web services

©Eastman Kodak Company, 2001

.NET Framework architecture What is the .NET framework?

VB C++ C# JScript … Visual Studio.NET

Common Language Specification

ASP.NET: Web Windows Services & Web Forms Forms ADO.NET: Data and XML

Common Language Runtime

Operating System

©Eastman Kodak Company, 2001

5 .Net Framework and CLR

• .Net languages compiled to Microsoft Intermediate Language (MSIL) • JIT compiler used to translate MSIL to executable code • MSIL is “managed code” which uses garbage collection • Network communication based on XML and SOAP

©Eastman Kodak Company, 2001

.NET Framework Execution .NET Framework

•Different Languages VB C#

•Compile

•Same IL MSIL MSIL

©Eastman Kodak Company, 2001

6 Common Language Runtime

©Eastman Kodak Company, 2001

.NET Framework And CLR CLR Execution Model

Source VB C# C++ code Unmanaged Compiler Compiler Compiler Component

Managed Assembly Assembly Assembly IL Code IL Code IL Code code

Common Language Runtime

JIT Compiler

Native Code

Operating System Services

©Eastman Kodak Company, 2001

7 Common Language Runtime Type System • All .Net languages use the same type system, so code in one language can call or inherit from classes written in another language without type conversions – Single-rooted type system (System.Object) unlike COM, CORBA, and Java • COM uses different type system than C++, so C++ COM programmers spend a lot of time dealing with type (e.g. BSTR, Variant, IUnknown)

©Eastman Kodak Company, 2001

Common Language Runtime Assemblies • Unit of deployment, versioning, security, code reuse • Contains – Manifest – Metadata – MSIL – Resources (optional)

©Eastman Kodak Company, 2001

8 Deployment

• XCopy deployment – No registration necessary • Side-by-side execution – Multiple versions of the same component can co-exist, even in the same process – Eliminates “DLL hell”

©Eastman Kodak Company, 2001

Deployment

• Assemblies can be private or shared • Default is private (unlike COM) • Private assemblies go in a program subdirectory • Shared assemblies go in (GAC) • Application configuration file (XML) can modify search path for assemblies ©Eastman Kodak Company, 2001

9 .Net Uses XML Extensively

• Network communication (SOAP) • Serialization – Persistence – Marshalling • Application configuration files • Used internally and supported by ADO.Net • Documentation in C# • And more…

©Eastman Kodak Company, 2001

SOAP

• XML-based messaging and RPC protocol • .Net replacement for DCOM • Not platform or language specific • Can go through firewalls • Uses HTTP as a transport • Can use with secure transport (eg. HTTPS) ©Eastman Kodak Company, 2001

10 .Net Languages

©Eastman Kodak Company, 2001

Microsoft’s .Net Languages

• C# • Visual Basic.Net • Managed Extensions for C++ • Jscript • ILAsm (Microsoft .Net IL Assembler)

©Eastman Kodak Company, 2001

11 Other .Net Languages

• COBOL (Fujitsu) • Eiffel • Perl • Python • Smalltalk • APL • Fortran

©Eastman Kodak Company, 2001

C#

• New language developed by Microsoft • Submitted to ECMA for standardization • Member of the C family • Influenced by C++, Java, VB, Delphi

©Eastman Kodak Company, 2001

12 C#

• Many similarities to Java – General syntax – Fully object-oriented – Single inheritance – Interfaces – All classes inherit from Object – Try/catch/finally

©Eastman Kodak Company, 2001

C#

• More similarities to Java – Thread synchronization – Garbage collection – Compiled to intermediate language

©Eastman Kodak Company, 2001

13 C#

• Differences from Java – Properties – Enums – Structs – Attributes – Delegates – Events

©Eastman Kodak Company, 2001

C#

• More differences from Java – Boxing – Namespaces – Foreach statement – Operator overloading – Pass by reference – XML documentation

©Eastman Kodak Company, 2001

14 C# - Boxing

• Everything in C# can be treated as an object – Including built-in types: integers, floats, etc. – 3.ToString() is legal C# • To avoid overhead, value types are normally handled on the stack • When an object reference is made against a value type, a “box” object

is created on©Eastman the Kodak heapCompany, 2001

C# - Attributes

• Attributes can be added to a module, class, method, property, parameter, etc. • Extensible • Example: WebMethod attribute in ASP.Net

[WebMethod] public string SayHello(string Name) { return “Hello “ + Name; }

©Eastman Kodak Company, 2001

15 C# - Delegates

• Delegates are objects that invoke methods on another object • Somewhat like C function pointers • Delegates extend System.Delegate (or a subclass) • Delegates are supported in C# and VB.Net, but syntax is different • Delegates provide support for asynchronous method invocation

©Eastman Kodak Company, 2001

Visual Basic .NET

• Next generation of Visual Basic • Fully object-oriented – Inheritance – Java-like exception handling • Other significant changes – will break many existing programs

©Eastman Kodak Company, 2001

16 Managed Extensions for C++ • Uses the services of the Common Language Runtime • Garbage collection • New (proprietary) keywords • New switch on C++ compiler: /CLR • Code compiled with /CLR is MSIL, with some exceptions

©Eastman Kodak Company, 2001

JUMP – Java User Migration Path • Three tools for using Java with .Net – Tool to allow developing .Net applications with Java syntax – Tool to allow running VJ++ code on .Net CLR (rather than JVM) – Source code conversion tool from Visual J++ to C# • Supports JDK 1.1.4 only • Announced in January but not yet available

©Eastman Kodak Company, 2001

17 Miscellaneous Topics

©Eastman Kodak Company, 2001

Visual Studio.Net

• Integrated design time environment. • Tools used across language. • Very rich help system. • RAD for desktop application and web application. • Web Forms, Win Forms

©Eastman Kodak Company, 2001

18 WinForms

• Windows Forms – framework for building rich client Windows applications • Usable by any .Net language • RAD design time experience • Visual Studio.Net uses WinForms • WinForms can host ActiveX Controls

©Eastman Kodak Company, 2001

ASP.Net

©Eastman Kodak Company, 2001

19 ASP Today • The leading web development platform – Nearly one million ASP developers • Simple and approachable development – HTML with embedded script – No compile required – “just hit save” • Relatively flexible and extensible – Supports multiple script languages – COM objects access resources, encapsulate business logic

©Eastman Kodak Company, 2001

Areas for Improvement • Allow clean separation of code and content • Require less code for common tasks • Allow compiled languages • Make deployment of components easier • Enable apps to work better in web farms • Provide a better architecture for tools

©Eastman Kodak Company, 2001

20 ASP.NET • The .NET web application server platform • Improved development platform – Rich page architecture – “Web Forms” – Great support for XML Web Services – Modular, factored architecture – Great tools support • Easier to deploy • Enhanced reliability and availability • Improved performance and scalability

©Eastman Kodak Company, 2001

ASP.NET Page Framework • Control-based, event-driven execution – “VB for the Web” – Much less code required than ASP – Cleanly encapsulated functionality • Uses compiled languages – VB, C#, Jscript – Executed via CLR as native code • ASP.NET pages use “.ASPX” extension – Runs side-by-side on IIS with current ASP applications

©Eastman Kodak Company, 2001

21 Caching Support • Full page output caching – Vary by params, language, user-agent • Fragment Caching – Enables portions of pages to be cached • Extensible Cache API – Developers can cache arbitrary objects – Multiple expiration policies, file change invalidation

©Eastman Kodak Company, 2001

PC Magazine Nile Application 2781 2800 Test 8 CPU Pages Served per Second 4 CPU 2400 2 CPU

2000 1989

1600

1200 1154

748 800 637 330 400

Microsof Microsof t t ©Eastman Kodak Company, 2001 ASP ASP.NET

22 Web Services in ASP.NET • Simple Programming Model – Author .ASMX Files with Class Methods – ASP.NET compiles on demand, generates contract, exposes HTML information page • Incoming HTTP requests invoke methods – No special HTTP or XML knowledge needed • Supports Multiple Message Wire Formats – HTTP Get, Post, and SOAP Requests

©Eastman Kodak Company, 2001

Open Source .Net Projects

• DotGNU (FSF): http://www.gnu.org/projects/dotgn u/ • project (Ximian): http://www.go-mono.com/

©Eastman Kodak Company, 2001

23 Where to Get More Information • http://msdn.microsoft.com/net/ • http://www.gotdotnet.com/ • http://csharpindex.com • http://www.csharp-station.com/ • DOTNET e-mail list (Developmentor) http://discuss.develop.com/archives/dot net.html • A number of .Net and C# books are available

©Eastman Kodak Company, 2001

Q&A

©Eastman Kodak Company, 2001

24