PowerPoint-presentasjon

Download Report

Transcript PowerPoint-presentasjon

Introduksjon til .NET
XXXXXXXXXXXXXXXXXXX
Jonas Follesø, Abeo AS
http://jonas.follesoe.no
[email protected]
Agenda
• Hva er .NET Framework
• The Common Language Runtime
• The Framework Class Libraries
• Støtte for flere progammeringsspråk
• Støtte for flere platformer
• Gode utviklingsverktøy
• Hvordan komme i gang?
• Demoer 
MICROSOFT NORGE
Hva er .NET?
• En utviklingsplattform: grensesnitt, komponenter og
verktøy for å utvikle programvare.
• Den største endringen i Microsofts utviklingsplattform
siden Windows NT erstattet DOS
• Hva er nytt?
– Programmerings språk, kompilatorer
– Måten kode er lastet og eksekvert
– Sikkerhetsmodell
– Objektmodell, metadata, distribuerte systemer
– Klassebiblioteker
– …
MICROSOFT NORGE
.NET - Microsofts visjon for programvare
• Gjøre distribuerte systemer tilgjeng via Internett
• Sømløs integrasjon mellom flere applikasjoner og
enheter
• Levere programvare som en tjeneste
• Neste generasjon brukeropplevelser
• .NET Framework er programmeringsmodellen som skal
lansere .NET visjonen.
MICROSOFT NORGE
.NET Framework
• Common Language Runtime (CLR)
C#
VB.NET
Web Forms
C++
J#
Web Services
Others
Win Forms
ADO.NET and XML
Base Class Libraries
–
Multi-language support
–
Common type system
–
Simplified deployment
–
Code Access Security
• Rich Class libraries
–
Powerful, Consistent Programming
Model
–
Focus on code, not plumbing
• Built for Tools
Common Language Runtime
MICROSOFT NORGE
–
Support for design-time functionality
–
Debugging, profiling, instrumentation
support
Common Language Runtime
DEVELOPMENT
public static void Main(String[] args )
{ String usr; FileStream f; StreamWriter w;
try {
usr=Environment.GetEnvironmentVariable("USERNAME");
f=new FileStream(“C:\\test.txt",FileMode.Create);
w=new StreamWriter(f);
public static void Main(String[] args )
w.WriteLine(usr);
{ String usr; FileStream f; StreamWriter w;
w.Close();
try {
} catch (Exceptionusr=Environment.GetEnvironmentVariable("USERNAME");
e){
Console.WriteLine("Exception:"+e.ToString());
f=new FileStream(“C:\\test.txt",FileMode.Create);
}
w=new StreamWriter(f);
}
w.WriteLine(usr);
w.Close();
} catch (Exception e){
Console.WriteLine("Exception:"+e.ToString());
}
}
Source code
MICROSOFT NORGE
Compiler
Assembly
C#
J#
VB
Cobol
…
MSIL
Metadata
Resources
Common Language Runtime
DEVELOPMENT
public static void Main(String[] args )
{ String usr; FileStream f; StreamWriter w;
try {
usr=Environment.GetEnvironmentVariable("USERNAME");
f=new FileStream(“C:\\test.txt",FileMode.Create);
w=new StreamWriter(f);
public static void Main(String[] args )
w.WriteLine(usr);
{ String usr; FileStream f; StreamWriter w;
w.Close();
try {
} catch (Exceptionusr=Environment.GetEnvironmentVariable("USERNAME");
e){
Console.WriteLine("Exception:"+e.ToString());
f=new FileStream(“C:\\test.txt",FileMode.Create);
}
w=new StreamWriter(f);
}
w.WriteLine(usr);
w.Close();
} catch (Exception e){
Console.WriteLine("Exception:"+e.ToString());
}
}
Assembly Compiler
Source code
C#
J#
VB
Cobol
…
DEPLOYMENT
Install Assembly
MSIL
Setup
Copy Metadata
Browser Resources
Click Once
Global
Assembly
Cache (GAC)
Application
Directory
Download
Cache
MICROSOFT NORGE
Common Language Runtime
DEPLOYMENT
DEVELOPMENT
Install
Assembly
Setup
Copy
Browser
Click once
EXECUTION
IL to Native
Compiler
Native .exe
+ GC table
Class
Loader
Code
Manager
Security
Assembly
Global
on Target Policy
Assembly
Machine
Cache
(GAC)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<mscorlib>
<security>
<policy>
<PolicyLevel version="1">
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="Nothing"
Name="All_Code"
Description="Code group
grants no permissio
ns and forms the root of the code group tree.">
<IMembershipCondition clas
s="AllMembershipCondition"
version="1"/>
<CodeGroup class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Application
Directory
Assembly
Loader
Download
Cache
Garbage Collection
Exception Manager
Thread Support
MICROSOFT NORGE
Debug Engine
COM Interop
.NET Namespace
System.Web
Services
Description
UI
HtmlControls
Discovery
WebControls
System.WinForms
Design
Protocols
ComponentModel
System.Drawing
Caching
Security
Drawing2D
Printing
Configuration
SessionState
Imaging
Text
System.Data
System.Xml
ADO
SQL
XSLT
Design
SQLTypes
XPath
Serialization
System
Collections
IO
Security
Configuration
Net
ServiceProcess
Runtime
InteropServices
Diagnostics
Reflection
Text
Remoting
Globalization
Resources
Threading
Serialization
CLR Design Goals
• Forenklet applikasjonsutvikling
• Robust og sikkert kjøremiljø for kode
• Støtte for flere programmeringsspråk
• Enklere utrulling og vedlikehold
MICROSOFT NORGE
Enklere utvikling
Windows API
HWND hwndMain = CreateWindowEx(
0, "MainWinClass", "Main Window",
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
(HWND)NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hwndMain, SW_SHOWDEFAULT);
UpdateWindow(hwndMain);
.NET Framework
Form form = new Form();
form.Text = "Main Window";
form.Show();
MICROSOFT NORGE
Enklere utvikling
• Organization
– Code organized in hierarchical namespaces and classes
• Unified type system
– Everything is an object, no variants, one string type, all
character data is Unicode
• Component Oriented
– Properties, methods, events, and attributes are first class
constructs
– Design-time functionality
MICROSOFT NORGE
Robust og sikkert
• Automatic lifetime management
– All .NET objects are garbage collected
– No stray pointers, no circular references
• Code correctness and type-safety
– IL can be verified to guarantee type-safety
– No unsafe casts, no uninitialized variables, no out-of-bounds
array indexing
• Evidence-based security
– Based on origin of code as well as user
– Extensible permissions
MICROSOFT NORGE
Støtte for flere språk
• Velg språk som passer deg
– All .NET funksjonalitet er tilgjennlig i alle
programmeringsspråk
– En applikasjon kan skrives i flere språk
– Debuggere, kodeanalyse, profilering osv fungerer for alle
språk.
• Tilgjenglie kompilatorer
– Fra Microsoft: VB, C++, C#, JScript, Java
– Fra andre: APL, COBOL, Eiffel, Fortran, Haskell, ML, Perl,
Python, RPG, Scheme, Smalltalk, …
MICROSOFT NORGE
Uniform programmeringsmodell
Consistent API availability regardless of
language and programming model
.NET Framework
RAD,
Composition,
Delegation
VB Forms
Subclassing,
Power,
Expressiveness
MFC/ATL
Windows API
MICROSOFT NORGE
Stateless,
Code embedded
in HTML pages
ASP
Bred støtte for flere språk
Dim s as String
s = "authors"
Dim cmd As New SqlCommand("select * from " & s, sqlconn)
cmd.ExecuteReader()
string s = "authors";
SqlCommand cmd = new SqlCommand("select * from "+s, sqlconn);
cmd.ExecuteReader();
VB.NET
C#
C++
String *s = S"authors";
SqlCommand cmd = new SqlCommand(String::Concat(S"select * from ", s), sqlconn);
cmd.ExecuteReader();
MICROSOFT NORGE
Bred støtte for flere språk
Perl
String *s = S"authors";
SqlCommand cmd = new SqlCommand(String::Concat(S"select * from ", s), sqlconn);
cmd.ExecuteReader();
s = "authors"
cmd =SqlCommand("select * from " + s, sqlconn)
cmd.ExecuteReader()
Python
assembly_external(name="System.Data.SqlClient.SqlCommand") Fortran
sqlcmdcharacter*10 xsqlcmd
Cmd x='authors'
cmd = sqlcmd("select * from "//x, sqlconn)
call cmd.ExecuteReader()
end
MICROSOFT NORGE
Bred støtte for flere språk
(let* ( (s "authors")
(cmd (new-SqlCommand (string-append "select * from " s) sqlconn)))
(execute-command cmd))
local
s: STRING
cmd: SQLCOMMAND
do
s := "authors"
create cmd("select * from " + s, sqlconn)
cmd.ExecuteReader()
end
Scheme
Eiffel
ExecuteReader = invoke System.Data.SqlClient.ExecuteReader();
SqlCommand = create System.Data.SqlClient.SqlCommand(String,\
System.Data.SqlClient.SqlConnection);
query = sqlconn -> let{ s = "authors"; } in {
cmd <- SqlCommand ("select * from "+s, sqlconn);
Mondrian
cmd # ExecuteReader();
};
MICROSOFT NORGE
Enklere utrulling og administrasjon
• Assemblies
– The unit of deployment, versioning, and security
– Like DLLs, but self-describing through manifest
• Zero-impact install
– Applications and components can be shared or private
• Side-by-side execution
– Multiple versions of the same component can co-exist, even
in the same process
MICROSOFT NORGE
Web Services
• Expose APIs across the Internet
– HTML == human -- machine
– XML/SOAP == machine -- machine
• Leverage the Web
– The same infrastructure
– Interoperability
• Distributed scalable applications
– Stateless
– Internet and Intranet
MICROSOFT NORGE
Web Services
The .NET Framework provides
a bi-directional mapping
Application
Concepts
Web
Framework
Data
XML
Objects
Schema
XSD
Classes
Services
WSDL
Methods
Invocation
SOAP
Calls
MICROSOFT NORGE
- Web Service demo, klient og
deployment
MICROSOFT NORGE
.NET Compact Framework
• .NET rammeverket på mobile enheter
– Subset av .NET Framework
• Samme utviklingsverktøy,
programmeringsspråk
og rammeverk
MICROSOFT NORGE
MICROSOFT NORGE
.NET oppsummering
• Microsoft satser tungt på .NET
–
–
–
–
–
–
–
–
–
Visual Studio 2005: 7.5 million lines
SQL Server 2005: 3 million lines
BizTalk Server: 2 million lines
Visual Studio Team System: 1.7 million lines
Windows Presentation Foundation: 900K lines
Windows Sharepoint Services: 750K lines
Expression Interactive Designer: 250K lines
Sharepoint Portal Server: 200K lines
Content Management Server: 100K lines
• Kan du .NET kan du enkelt programmere mot
“alle” nye Microsoft produkter
• WinFX kommer, bygd på toppen av. NET
MICROSOFT NORGE
Hvordan komme i gang?
• Last ned Visual Studio Express Editions
– http://msdn.microsoft.com/express
• For mer informasjon om .NET
– http://msdn.microsoft.com/netframework
• To gode boktips
– Microsoft® Visual C#® 2005 Express Edition: Build a Program Now!
– Microsoft® Visual Web Developer™ 2005 Express Edition: Build a
Web Site Now!
MICROSOFT NORGE
Materiell
• I posen har du informasjon/tilbud fra Microsoft og
partnere, godis og skrivesaker
• Bakerst i rommet finner du materiell tilpasset denne
sesjonen. Forsyn deg!
• Vi setter pris på tilbakemeldinger på materiellet dere
får utdelt.
MICROSOFT NORGE
Til slutt….
• Hjelp oss å bli bedre
– Fyll ut evalueringen som kommer på e-post
– Gi direkte råd til Microsoft-representanter
• Hold deg oppdatert
– www.microsoft.no/informasjon eller fyll ut et Hold deg
oppdatert kort
– Besøk oss på www.microsoft.no
MICROSOFT NORGE