The .Net Framework

30
The .Net Framework A Brief Overview

description

The .Net Framework. A Brief Overview. Introduction. Major shift in technology Like previous technologies, such as “ActiveX”, .Net is more a brand than a single technology. Main parts. .Net framework Visual Studio.Net .Net My services .Net Enterprise Servers. .Net Framework. - PowerPoint PPT Presentation

Transcript of The .Net Framework

Page 1: The .Net Framework

The .Net Framework

A Brief Overview

Page 2: The .Net Framework

Introduction

• Major shift in technology

• Like previous technologies, such as “ActiveX”, .Net is more a brand than a single technology.

Page 3: The .Net Framework

Main parts

• .Net framework

• Visual Studio.Net

• .Net My services

• .Net Enterprise Servers

Page 4: The .Net Framework

.Net Framework

• An environment for creating applications• Previous DNA technologies

– E.g., COM, COM+, DCOM, ADO, ActiveX, ASP, VB, C++

• MS DNA didn’t provide a common foundation for application development.– Scripting vs. compiled; calls to OS; separate runtime

libraries; separate types; no common architecture

• MS DNA grew incrementally without any real master plan by different groups at different times within MS.

Page 5: The .Net Framework

.Net Framework

• For MS DNA technologies, COM was the glue: provides common conventions for interfaces etc. DCOM provides remote access to binaries etc.

• With .Net, this “glue” technology is unnecessary

• Where there firewall issues with COM?

• .Net uses the http ports

Page 6: The .Net Framework

.Net Framework

Windows

Browser Web Services Local Other

Applications

Common Language Runtime

.Net Framework Class Library

ASP.NET ADO.NETWindows

FormsEnterpriseServices

Page 7: The .Net Framework

.Net Framework

• Software written to run within the framework is called managed code.

• The objects created by developers can inherit the Framework’s Class Library code.

• For example, ASP web pages inherit the Class Library’s Page class.

Page 8: The .Net Framework

The managed object I created “exerciseInterface.aspx”, inherits the class library code in System.Web.UI.Page.

Page 9: The .Net Framework

Framework Class Library

• Organized as a hierarchy of namespaces

• For example, the class that creates a connection to a SQL Server database is in the namespace– System.Data.SQLclient

Page 10: The .Net Framework

Connection, DataAdpater

System

Windows Data

SqlClient

Web

Forms

This library is huge!

Page 11: The .Net Framework

To make a connection to a SQL Database using the SQLconnection class, you reference the SqlClient namespace. You place the import statement at the top of the page before declaring the class. The Imports statement eliminates the need to explicitly qualify the reference. In C#, of course, that a “using” clause.

Page 12: The .Net Framework

Standard Class Library

• Standard class libraries aren’t new.– The point of such libraries is to speed development and

increase the quality of software.– JAVA and C++?

• A problem with such libraries is that they can become so large and complex that they are unusable. Abstraction isn’t free. Complexity doesn’t go away…– What is complexity? A definition?

• The basic trade-off is between power and complexity. As a library becomes more powerful, it becomes more complex.

• Fortunately, a developer can use a subset of the library and ignore what isn’t relevant.

Page 13: The .Net Framework

Common Language Runtime

• The CLR provides a standard implementation for a modern object-oriented programming language.– What does this mean actually?

• “Once you have learned how to program, it is easy to pick-up or learn other languages.” [true?]

• Syntax versus semantics

Page 14: The .Net Framework

Common Language Runtime

• Syntax vs. Semantics– Although the syntax of most modern programming

languages differ, the underlying abstractions are very similar.

– The CLR provides the semantics that any language can be mapped to. Thus syntax and semantics are separated. (staple concept in compiler design)

• Benefits?– Portability (at least for mobile devices etc)

– Better security because it will not contain arbitrary memory addresses and the like. It is easier to create a “sand-box” in which the application can “play.” Scope security.

Page 15: The .Net Framework

Common Language Runtime

• Syntax vs. Semantics– But won’t this lead to slower execution?

• Could. It depends on the application• Similar arguments used by Sun to justify the

slower speed of Java.• Hardware is getting faster…

Page 16: The .Net Framework

Common Language Runtime

• The CLR provides technologies for packaging and executing managed code.

• When managed code is compiled, two things are produced: Microsoft Intermediate Language MSIL and metadata.

Page 17: The .Net Framework

Common Language Runtime

Execution

SourceCode

LanguageCompiler

MSIL,MetaData

JITCompiler

Compilation

MachineSpecificBinary

(ExerciseInterface.aspx.vb)

Page 18: The .Net Framework

When I do a “build” of my managed code, it is compiled into MSIL along with it’s metadata as a Portable Executable (PE). This file can be a DLL or an EXE file. This is the actual file that the Web sever will JIT compile into a machine specific binary when a managed object is requested for the first time.

Page 19: The .Net Framework

MSL

• MSL is a set of CPU-independent instructions for performing operations etc (semantics).– Syntax semantics machine specific binary

• VB.Net and C# have roughly the same capabilities– In fact, some of the syntax is interchangeable with the addition of

“;” and “{}”s. Why?– Are the “language wars” over?– Why was BASIC (1960), Visual Basic (1991), and then VB.Net

(2000) released? Or I should say “for whom?” – C# was created as an entirely new language. Why? Why not just

create C++.Net?• C++ will remain the dominant platform for non.Net processor-

specific binaries? Don’t know…• Object.method.property[something].somethingelse().tostring

Page 20: The .Net Framework

MSL

• It is worth noting that the .Net Framework Class Library is written in C#– Some suggest that MS will eventually phase

out VB and support only C#

Page 21: The .Net Framework

MetaData

• Name, methods, properties, events etc

• Think “Intelli-sense.” The dropdown list is populated from the metadata.

Page 22: The .Net Framework

Assemblies

• Assemblies is how .Net organizes managed code.

• An assembly is a logical construct. That is, there isn’t a file that contains the managed code files.

• The list of files “contained” in an assembly is called the manifest.– A manifest is like metadata for the assembly

Page 23: The .Net Framework

Manifest

• An assembly’s manifest contains the assembly’s name, it’s version number, dependencies and of course, the files contained in the assembly.

• The manifest is stored as part of one of the files in the assembly.

• Assemblies can eliminate “DLL hell.”– Multiple versions of an assembly can run at the same

time thus removing potential conflicts

Page 24: The .Net Framework

Managed code is organized into Assemblies. The files in an assembly are identified by it’s Manifest.

The System.Reflection Namespace provides a standard means of reading and interpreting an assemblies manifest. Reflection enables Visual Studio’s IntelliSense.

A manifest contains it’s name, version number, language, list of files, other assemblies it relies on. This reduces the risk of exposure to DLL Hell. If the developer is careful about versioning, diverse assemblies can be installed side-by-side without conflict.

Page 25: The .Net Framework

Assembly for Web Projects?

– If you create your presentation tier as a new web site

• File > New > Web Site... • VS will not create an assembly of managed code

– If you create your presentation tier as a new web application project

• File > New > Project... • VS will create the assembly

Page 26: The .Net Framework

Assembly for Web Projects?

– Web site is the default. The subfolder of the website project acts as an assembly. If the file is in the folder, it is part of the assembly.

– Developers asked for a means to create explicit assemblies for web site projects. Especially for those created in VS 2003. The change from 2003 to 2005 was significant and conversion is not easy… A web application project allows the developer to explicitly specify project structure.

Page 27: The .Net Framework

Just-in-time compilation

• Each method in an MSIL assembly is compiled only when it is first called.– Or if an assembly changes

• Compiled code is not saved but recompiled again if needed (say after a reboot or the application is stopped)

• What is the impact of JIT for deployment?

Page 28: The .Net Framework

Common Language Runtime

• MSIL versus Java ByteCode– Very similar– ByteCode was designed to be either compiled

or interpreted. MSIL was designed for compilation only

• CLR versus Java Virtual Machine• Roughly equal

Page 29: The .Net Framework

JAVA Environment

Windows, Solaris, Linux, Others

Browser Web Services Local Other

Applications

Java Virtual Machine (VM)

Standard Java Packages

JavaServerPages

JDBC SwingEnterpriseJavaBeans

Page 30: The .Net Framework

Common Language Runtime

• Java is write-once run-many; diverse operating systems

• .Net focuses on Windows

• The Java environment requires Java

• .Net allows multiple languages