.NET Framework Overview

Download Report

Transcript .NET Framework Overview

Microsoft .NET Framework

Overview

Svetlin Nakov

http://www.nakov.com

Software Development Consultant, Part-time Computer Science Lecturer Sofia University “St. Kliment Ohridski”

.NET Enterprise Vision

Users

Any device, Any place, Any time

Notification Scheduling Authentication XML Web Services

Integrate business applications and processes

Back Office

Heterogeneous application and server infrastructure

Sales ERP & Billing Customer Service

.NET Framework

Programming model for .NET

Platform for running .NET code in a managed environment

Provides a very good environment to develop networked applications and Web Services

Provides programming API and unified language-independent development framework

Code runs on multiple platforms (Windows, Linux, FreeBSD, …)

The Core of .NET Framework: FCL & CLR

Common Language Runtime

Garbage collection

Language integration

Multiple versioning support for assemblies (no more DLL hell!)

Integrated security

Framework Class Library

Provides the core functionality: ASP.NET, Web Services, ADO.NET, Windows Forms, IO, XML, etc.

.NET Framework

Common Language Runtime

   

CLR manages code execution at runtime Memory management, thread management, etc.

Code-based security Role-based security Common Language Runtime Operating System

.NET Framework

Base Class Library

 

Object-oriented collection of reusable types Collections, I/O, Strings, … .NET Framework (Base Class Library) Common Language Runtime Operating System

.NET Framework

Data Access Layer

Access relational databases

Disconnected data model

Work with XML ADO .NET and XML .NET Framework (Base Class Library) Common Language Runtime Operating System

.NET Framework

ASP.NET & Windows Forms

Create application’s front-end – Web-based user interface, Windows GUI, Web services, … ASP .NET

Web Forms Web Services Mobile Internet Toolkit

ADO .NET and XML Windows Forms .NET Framework (Base Class Library) Common Language Runtime Operating System

.NET Framework

Programming Languages

Use your favorite language C++ C# VB.NET

Perl ASP .NET

Web Forms Web Services Mobile Internet Toolkit

J# ADO .NET and XML … Windows Forms .NET Framework (Base Class Library) Common Language Runtime Operating System

.NET Framework

Common Language Specification C++ Common Language Specification … ASP .NET

Web Forms Web Services Mobile Internet Toolkit

Windows Forms ADO .NET and XML .NET Framework (Base Class Library) Common Language Runtime Operating System

.NET Framework

Visual Studio .NET

C++ C# VB Perl J# … Common Language Specification ASP .NET

Web Forms Web Services Mobile Internet Toolkit

Windows Forms ADO .NET and XML .NET Framework (Base Class Library) Common Language Runtime Operating System

Multiple Language Support

IL (MSIL or CIL) – Intermediate Language

It is low-level (machine) language, like Assembler, but is Object-oriented

CTS is a rich type system built into the CLR

Implements various types (int , float, string, …)

And operations on those types

CLS is a set of specifications that all languages and libraries need to follow

This will ensure interoperability between languages

Example of MSIL Code

.method private hidebysig static void Main() cil managed { .entrypoint

// Code size 11 (0xb) .maxstack 8 IL_0000: ldstr "Hello, world!" IL_0005: call void [mscorlib]System.Console::WriteLine(string) IL_000a: ret } // end of method HelloWorld::Main

.NET Languages

   

Languages provided by Microsoft

C++, C#, J#, VB.NET, JScript Third-parties languages

Perl, Python, Pascal, APL, COBOL, Eiffel, Haskell, ML, Oberon, Scheme, Smalltalk… Advanced multi-language features

 

Cross-language inheritance and exceptions handling Single project can share code written in multiple languages Integration is built in, not bolted on

No additional rules or API to learn

C# Language

  

Mixture between C++, Java and Delphi Component-oriented

   

Properties, Methods, Events Attributes, XML documentation All in one place, no header files, IDL, etc.

Can be embedded in Web applications Everything really is an object

Primitive types aren’t magic, e.g.

5.ToString() is valid

 

Unified type system == Deep simplicity Good extensibility and reusability

C# Language – Example

using System; class HelloWorld { public static void main() { Console.WriteLine(“Hello, world!”); } }

Code Compilation and Execution

Source Code

Compilation

Language Compiler Code MSIL Metadata

Also called Assembly (.EXE or .DLL file)

Native Code

Execution

JIT Compiler

- First time each method is called - Install time precompilation

VS.NET – Single Development Environment & Skill Set

   

From Visual Studio.NET you can:

    

Write code Design user interface Study documentation Execute, test and deploy Debug Same tools for all languages Same tools for all platforms Same tools for all technologies

Visual Studio .NET

The .NET Framework Library

ASP.NET

Web Forms Web Services Mobile Internet Toolkit Windows Forms ADO.NET and XML Base Class Library

.NET Framework Namespaces

Services Description Discovery Protocols System.Web

UI HtmlControls WebControls Caching Configuration Security SessionState ADO Design System.Data

SQL SQLTypes Collections Configuration Diagnostics Globalization IO Net Reflection Resources Design System.WinForms

ComponentModel System.Drawing

Drawing2D Imaging Printing Text XSLT XPath System.Xml

Serialization System Security ServiceProcess Text Threading Runtime InteropServices Remoting Serialization

Base Class Library Namespaces

System Collections Configuration Diagnostics Globalization IO Net Reflection Resources Security ServiceProcess Text Threading Runtime InteropServices Remoting Serialization

Base Class Library

         

Data types, conversions, formatting Collections: ArrayList, Hashtable, etc.

Globalization: Cultures, sorting, etc.

I/O: Binary and text streams, files, etc.

Networking: TCP/IP sockets, HTTP, etc.

Reflection: Metadata and IL emit Security: Permissions, cryptography Text: Encodings, regular expressions Multithreading and synchronization Remoting and serialization

Data And XML Namespaces

System.Data

OleDb Common SQLClient SQLTypes System.Xml

XSLT XPath Serialization

ADO.NET And XML

ADO.NET consumes all types of data

XML (hierarchical), relational, etc.

Powerful in-memory data cache (DataSet)

DataSet contains various data objects: tables, views, relations, constraints, etc.

Lightweight, stateless, disconnected

Supports both relational and XML access

High-performance, low overhead stream access

Great XML support including:

W3C DOM, XSL/T, XPath, and Schema

VS.NET – DataSet Designer

Windows Forms Namespaces

System.Windows.Forms

Design ComponentModel System.Drawing

Drawing2D Imaging Printing Text

Windows Forms

Windows Forms is framework for building rich GUI applications

     

RAD (Rapid Application Development)

component-based

event-driven Rich set of controls Data aware components Printing support Unicode support UI inheritance

VS.NET – Windows Forms Designer

Demo 1

Create simple database application with:

Windows Forms

ADO.NET

MS SQL Server

Visual Studio .NET

Demo 1 – Architecture

Application SqlConnection Database Microsoft SQL Server DataGrid SqlDataAdapter Fill Update DataSet

ASP.NET Namespaces

System.Web

Services Description Discovery Protocols Caching Configuration UI HtmlControls WebControls Security SessionState

ASP.NET

Framework for building Web applications and Web services in any .NET language

 

C#, C++, VB.NET, JScript, etc.

Automatic multiple clients support

DHTML, HTML 3.2, WML, small devices

Compilation of ASP.NET Web applications into .NET assemblies

Cached the first time when called

 

All subsequent calls use the cached version Separation of code and content

Developers and designers can work independently

ASP.NET

      

Rich set of ASP.NET server controls

 

Data validation Data bound grids Event-driven execution model Great Web-services support Easy to deploy High reliability and availability High performance and scalability Scalable handling of state information

VS.NET – Web Forms Designer

ASP.NET WebMatrix

Demo 2

Create simple Web-based database application with:

ASP.NET (Web Forms)

ADO.NET

MS SQL Server

MS Internet Information Server

Visual Studio .NET

Demo 2 – Architecture

Web Application SqlConnection Database Microsoft SQL Server DataGrid SqlDataAdapter Fill Update DataSet

Web Services

 

Web Services are programmable components accessible remotely over the Web

Built on the standards HTTP, XML and SOAP

Each service is described in WSDL

 

Easy accessible from any client on any platform “Request-response” execution model – like component-based programming over the Web ASP.NET – Simple programming model for Web Services development

 

Author .ASMX files with normal class methods ASP.NET compiles on demand, generates WSDL contract, exposes HTML test page

Web Service Example in C#

ParcelTracker.asmx

<%@ WebService Language="C#" %> using System; using System.Web.Services; public class ParcelTrackerWebService { [WebMethod] public string GetOrderStatus(int orderNumber) { // Implementation here } }

Demo 3

Create simple Web Service with:

ASP.NET (Web Services)

MS Internet Information Server

Visual Studio .NET

Shared Source CLI (Rotor)

    

Non-commercial CLI implementation, available as source code. Contains:

  

Managed execution environment for MSIL with JIT-compiler Compiler for C# and Jscript Set of development tools – ilasm, ildasm, cordbg, metainfo, … Implemented entirely in C++ and C# Compiles with MS Visual Studio .NET

Available for research, academic, teaching and other non-profit use Works on FreeBSD, Windows and Mac OS

.NET Framework – Resources

Visit following web sites:

 

.

NET Framework Home Site – http://msdn.microsoft.com/netframework/ Microsoft .NET Framework Community – http://www.gotdotnet.com/

ASP.NET – http://www.asp.net/

  

.NET Windows Forms – http://www.windowsforms.net/ O’Reilly .NET Community Site – http://www.ondotnet.com/ Microsoft Patterns and Practices – http://msdn.microsoft.com/practices/

Code Project – http://www.codeproject.net/

.NET Framework – Resources

 

Visit following web sites:

 

Mono – Open Source .NET Framework – http://www.go-mono.org/ Rotor – MS Shared Source .NET CLI – http://msdn.microsoft.com/net/sscli/

.NET Framework Course in Sofia University – http://www.nakov.com/dotnet/ Read the news groups:

 

.NET Framework Official News Group dotnet.framework

– news://msnews.microsoft.com/microsoft.public.

The Bulgarian Developers’ Newsgroup – news://msnews.microsoft.com/microsoft.public.

bg.developer

Questions?

My Questions

How can we create .NET Framework applications that run on mobile devices (such as mobile phones, PDA, handhelds, …)?

Answer:

Microsoft .NET Compact Framework

Standard part of MS Visual Studio .NET 2003

My Questions

How can we precompile .NET assemblies to speedup their execution? Any standard tool?

Answer:

Use the tool ngen.exe

It is standard part of .NET Framework

My Questions

MSIL is great for decompiling. How can we protect our .NET code from reverse engineering attacks?

Answer:

Use obfuscation tools like Dotfuscator