Introduction
What is .Net? • The hype: “Microsoft .Net is a set of Microsoft software technologies for connecting information, people, systems, and devices. It enables a high level of software integration through the use of XML Web services – small, discrete, building-block applications that connect to each other as well as to other applications over the Internet.”
What is .Net, really? • .Net is a platform that provides a standardized set of services. – It’s just like Windows, except distributed over the Internet. – It exports a common interface so that it’s programs can be run on any system that supports .Net.
Goals of .Net • • • •
Maintain Microsoft dominance…? Tie all devices to the Internet Software as a service Data and applications accessible on all devices – Truly compile once, run anywhere – Scalability
How Does It All Work? • Based on 3 protocols: – HTTP – XML – SOAP
• XML (eXtensible Markup Language) – Separates data and view – Good, general way of describing data
Simple Object Access Protocol • Definition: “Simple and lightweight mechanism for exchanging structured and typed information between peers in a decentralized, distributed environment.”
• Based on XML and HTTP – SOAP defined through XML – XML piggybacks on top of HTTP – Because it uses HTTP, firewalls aren’t a problem
.Net Platform • .Net Framework and Visual Studio .Net • Mobile Internet Toolkit – Set of programming interfaces that enable developers to target mobile devices like smart phones and PDAs
• Building Block Services (ie, Passport)
.Net Framework • Programming model for .Net • Platform for running managed code in a virtual machine • Provides a very good environment to develop networked applications and Web Services
.Net Framework Contents • Common Language Runtime • Manages running code • Verifies type safety • Provides garbage collection, error handling
– Provides common type system – Provides access to system resources • Win32 API, COM, etc.
• A collection of unified classes • ASP.NET • ADO.NET • Access to Windows Functions: System, System.Drawing, System.Web, System.XML...
Inside the .Net Framework Visual Basic .NET
ASP .NET
C#
ADO .NET
Visual J#...
Enterprise Services
CLR MSMQ
Active COM+ Directory
IIS
Win32 CLR Executes code, maintains security, handles component “plumbing” and dependencies
WMI
Unified Class libraries Unifies Programming models across languages Factored for extensibility Designed for tools Enterprise Services The services required for mission critical applications: Transactions, Messaging, Partitions, Object Pooling and Events XML and Data Access ADO .NET interfaces any database, loosely coupled data access and native XML data format. XML Web Services and Scripting High-productivity environment for building and operating XML Web services
Standards Compliance VB
C#
C++ JScript
J#...
XML Web services
Web Forms Windows Forms
Data and XML Base Class Library CLR CLI
Open Language Specification Visual Studio .NET
Common Language Specification
CLI, C# Submitted to ECMA
XML, SOAPbased XML-based data access
Common Language Runtime • Manages running code – Threading – Memory management – No interpreter: Install time or run time intermediate language (IL) to native compilation
• Fine-grained evidence-based security – Code access security • IL can be verified to guarantee type safety • No unsafe casts, no un-initialized variables and no out-ofbounds array indexing
– Role-based security – Integrated with underlying OS
Compilation and Execution Cycle Compilation Source Code
Language Compiler
Execution Native Code
JIT Compiler
Code MSIL Metadata
Before installation or the first time each method is called
CLR Internals Base Class Library Support Thread Support
COM Marshaler
Type Checker
Exception Manager
Security Engine
Debug Engine
IL to Native Compilers
Code Manager Class Loader
Garbage Collector
Simplified Development • CLR makes things easy: – Self-describing components – Hierarchical namespaces – Source code to metadata – Structured exceptions – Root object class – Garbage collector
.Net Unified Classes System.Web (ASP .NET) Services Description
UI HTMLControls
Discovery
WebControls
System.Windows.Forms Design
System.Drawing
Protocols Caching
Security
Configuration
SessionState
ComponentModel
Drawing2D Imaging
System.Data (ADO .NET)
Printing Text
System.XML
OLEDB
SQLClient
XSL
Serialization
Common
SQLTypes
XPath
Schema
System Collections
IO
Security
Runtime InteropServices
Configuration
Net
ServiceProcess
Diagnostics
Reflection
Text
Remoting
Globalization
Resources
Threading
Serialization
Multi-Language Development • Object system is built in, not bolted on – Use the language of choice – No additional rules or API to learn
• Advanced multi-language features – Cross-language inheritance and exceptions
• Supports more than 20 languages – Perl, Python, COBOL, Jscript, Eiffel, Haskell, Pascal, ML, ADA, APL, C, Visual C++, Visual J#, Visual Basic, Visual C#, SmallTalk, Oberon, Scheme, Mercury, Oz and CAML.
• All languages have approximately same performance, since all turn into MSIL first. • C# is the “flagship” language for the .NET Framework. • Tools that work in multiple languages and across languages and platforms – Debugger
Simple to Use • Component-oriented – Properties, methods and events are first class – Design-time functionality
• Organization – Organized in hierarchical namespaces
• Unified Type System – Everything is an object – Boxing converts value types to objects • No need for special variant type • Example: 123.toString(); will convert the integer “123” to a string “123”; without the need to declare “123” as an integer first
Summary • Microsoft .NET – – – –
Built from the ground up (unlike MFC) Standards-based platform Web services Consistent programming model
• The .NET Platform contains: – .NET Framework and Visual Studio .NET – Mobile Internet Toolkit – Building block services (Passport) • Common framework for all languages – Common Language Runtime and Unified classes
• Simplified development and deployment
Resources • http://www.gotdotnet.com – GotDotNet is a great site for code samples, tutorials, and a great developer community. Also access to the creators of C#.
• http://www.go-mono.com – Project Mono is an open source .NET implementation for Unix
• http://www.dotnetmagic.com – DotNetMagic has a great set of libraries and code to make common tasks very easy to perform.
• http://www.codeproject.com – Lots of code samples and resources for all programming languages.
• http://msdn.microsoft.com – Great for documentation on everything .NET & Win32 related.