300 likes | 432 Views
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.
E N D
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 • 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.
.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
.Net Framework Applications Browser Web Services Local Other .Net Framework Class Library ASP.NET ADO.NET Windows Forms Enterprise Services Common Language Runtime Windows
.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.
The managed object I created “exerciseInterface.aspx”, inherits the class library code in System.Web.UI.Page.
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
Connection, DataAdpater System Windows Data Web Forms SqlClient This library is huge!
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.
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.
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
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.
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…
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.
Common Language Runtime Compilation (ExerciseInterface.aspx.vb) Source Code Language Compiler MSIL, MetaData Execution Machine Specific Binary JIT Compiler
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.
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
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#
MetaData • Name, methods, properties, events etc • Think “Intelli-sense.” The dropdown list is populated from the metadata.
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
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
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.
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
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.
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?
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
JAVA Environment Applications Browser Web Services Local Other Standard Java Packages JavaServerPages JDBC Swing Enterprise JavaBeans Java Virtual Machine (VM) Windows, Solaris, Linux, Others
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