.NET Background v1.1 - PowerPoint PPT Presentation

1 / 38
About This Presentation
Title:

.NET Background v1.1

Description:

namespace Hello. public class Hello. static void Main() System.Console.WriteLine ('Hello World in C#'); System.Console.ReadLine ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 39
Provided by: patpa
Category:
Tags: net | background | hello

less

Transcript and Presenter's Notes

Title: .NET Background v1.1


1
.NET Backgroundv1.1
2
topics
  • simplest C program
  • .NET technology overview
  • getting the software you need
  • why did Microsoft create .NET and C?
  • .NET assemblies and components

3
1 the simplest C program
4

Hello World in C and C
  • namespace Hello
  • public class Hello
  • static void Main()
  • System.Console.WriteLine ("Hello World
    in C")
  • System.Console.ReadLine()

include int main()
printf(Hello World in C\n") return 0
5
Hello World in C and Java
namespace Hello public class Hello
static void Main(string args)
System.Console.WriteLine ("Hello world in
C") System.Console.ReadLine()
  • public class Hello
  • public static void main(String args)
  • System.out.println("Hello world in
    Java")

6
Hello World in C and VB.NET
  • // HelloWorld.cs
  • namespace Hello
  • public class Hello
  • static void Main()
  • System.Console.WriteLine ("Hello World
    in C")
  • System.Console.ReadLine()

HelloWorld.vb Module HelloWorld Sub
Main System.Console.WriteLine(Hello World in
VB.NET) System.Console.ReadLine()
End Sub End Module
7
2 .NET technology overview
8
C is a .NET framework language
  • C is part of Microsofts .NET framework
  • C compiler first available in 2002
  • C programs can run on almost all versions of
    Windows
  • to run, C programs require the .NET runtime
  • a.k.a. the .NET common language runtime (CLR)
  • the runtime does not yet come built-in to
    Windows
  • it is free but must be downloaded and installed
    separately
  • or must be installed by the C program installer
  • the CLR is analogous to the Java Virtual Machine
  • which also often requires a separate installation
    step
  • the C compiler itself is also free
  • It is part of the free .NET framework software
    development kit (SDK)
  • the SDK is a free download from Microsofts
    website

9
Just in Time (JIT) compiler in .NET runtime
Compilation
before installation, or the first time each
method is called
10
C uses the .NET libraries
  • C programs can call a huge body of pre-written
    code
  • called the Framework Class Libraries (FCL)
  • sometimes also called the Base Class Libraries
  • the .NET framework libraries are analagous to the
    Java APIs
  • Java and C libraries are similar in size and
    scope
  • many of the library class names are similar or
    identical
  • this helps Java programmers to get started in C
  • these libraries are designed to be used from
    within any .NET language

11
FxCL
  • .NET Framework Class Librarycontains 1000's of
    classes
  • Organized by namespaces
  • System
  • System.Data
  • System.Windows.Forms
  • etc.
  • Compiled into assemblies
  • mscorlib.dll
  • System.dll
  • System.Data.dll
  • System.Windows.Forms.dll
  • etc.

12
Overview of the .NET Framework Classes
System.Web (ASP .NET)
System.Windows.Forms
Services
UI
Design
ComponentModel
HTMLControls
WebControls
System.Drawing
Drawing2D
Printing
Caching
Security
Imaging
Text
Configuration
SessionState
System.Data (ADO .NET)
System.XML
OLEDB
SQLClient
XSL
Serialization
Common
SQLTypes
XPath
Schema
System
Collections
IO
Security
Runtime
InteropServices
Configuration
Net
ServiceProcess
Remoting
Reflection
Diagnostics
Text
Serialization
Threading
Resources
Globalization
13
Microsofts .NET compilers
  • the .NET software development kit (SDK) includes
    four compilers
  • C
  • similar to Java in many, but not all, respects
  • Java has 55 keywords
  • C has 83 keywords
  • VB.NET
  • capable of being fully object-oriented but also
    capable of expression far outside the bounds of
    object-oriented languages
  • VB.NET has 150 keywords
  • C
  • nearly ANSI-standard C compiler
  • language of choice for OS work and legacy apps
    (e.g. MS Office)
  • operates in two modes
  • managed mode generates .NET IL code
  • unmanaged mode generates native x86 code
  • J
  • Java 1.4 syntax, full FxCL, partial JCL (1.1.8
    SWING)

14
.NET versions
  • by default, .NET is version-aware
  • application is dependent upon version of .NET it
    is compiled against
  • application wont run unless that version of .NET
    is installed
  • compiled with VS .NET 2002? .NET v1.0 must be
    installed
  • compiled with VS .NET 2003? .NET v1.1 must be
    installed
  • compiled with VS .NET 2005? .NET v2.0 must be
    installed
  • note that app.config files provide a way around
    this
  • discussion beyond the scope of todays workshop

15
3 getting the software you need
16
getting the free .NET runtime and the free C
compiler
  • http//msdn.microsoft.com/netframework/downloads/u
    pdates/default.aspx
  • if this link breaks, just go to the MSDN website
    and search for the exact titles below
  • to run .NET and C programs, download and install
    the runtime
  • Microsoft .NET Framework Version 2.0
    Redistributable Package (x86) 23 Mb
  • after installing the runtime, download the
    software development kit (SDK) to get the
    command-line C compiler
  • .NET Framework 2.0 Software Development Kit (SDK)
    (x86) - 362 MB

17
console commands for compiling Java and C.NET
java hello
hello.exe
18
compiling C from the command line
  • download and install the Open Command Window
    Here power toy for Windows XP
  • http//www.microsoft.com/windowsxp/downloads/power
    toys/xppowertoys.mspx
  • using Windows Explorer, browse to the \bin
    subdirectory of your installation
  • for me, thats D\vstudio8\SDK\v2.0\Bin
  • in Windows Explorer, right-click on the above
    folder and select Open Command Window Here
  • in the console window, run SDKVARS32.bat
  • It sets the path and environment variables to
    enable command line builds
  • SDKVARS32.bat can vary from machine to machine
  • rerun setup to replace the missing file
  • type the name of the compiler executable file
    (csc.exe) on the command line, such as
  • csc /referencemetad1.dllmetad2.dll
    /outout.exe input.cs

19
C integrated development environments (IDEs)
  • Visual Studio .NET
  • sold by Microsoft
  • latest version is VS.NET 2005 (just released)
  • completely graphical, wizards for many common
    tasks
  • available for Windows NT, 2000, XP Pro, 2003
  • I only own a Mac OS X do I have to buy Windows
    to learn C?
  • get Virtual PC
  • it can allow you to run the .NET framework and
    Visual Studio .NET
  • there is a well-respected IDE by Borland that
    supports C
  • I think it has been, or shortly will be, updated
    to .NET 2.0
  • there is also an open source IDE (or two) out
    there
  • I havent tried any of them
  • develop, a simplified clone of VS.NET
  • MonoDevelop, a .NET IDE for Linux
  • WebMatrix, for building web-based .NET
    applications

20
parts of .NET supplied by Microsoft
download free Software Development Kit (SDK)
free download
21
4 why did Microsoft create .NET and C?
22
Microsofts big headache
  • prior to .NET, Microsoft had a big headache
  • Microsoft was supporting too many operating
    systems
  • application programming interfaces (APIs) were
    implemented as dynamic link libraries (DLLs)
    develop using C
  • calling the Windows API was different on every
    operating system
  • developers first had to find out exactly what
    kind of system the program was running on
  • and then determine if the API desired was
    actually installed on the system
  • that doesnt sound so bad
  • after all, there are only a few different kinds
    of Windows
  • right?

23
party trivia question
  • how many different versions of the Windows
    operating system exist, which have their own
    distinct mix of APIs? select the closest
    answer
  • 5
  • 15
  • 25
  • 35

24
Windows versions which can run the .NET framework
  • Windows XP Professional x64 Edition
  • Windows Server 2003, Standard x64 Edition
  • Windows Server 2003, Enterprise x64 Edition
  • Windows Server 2003, Datacenter x64 Edition
  • Windows Server 2003 R2, Standard x64 Edition
  • Windows Server 2003 R2, Enterprise x64 Edition
  • Windows Server 2003 R2, Datacenter x64 Edition
  • Windows Server 2003 with SP1, Enterprise Edition
    for Itanium-based Systems
  • Windows Server 2003 with SP1, Datacenter Edition
    for Itanium-based Systems
  • Windows Server 2003 R2, Enterprise Edition for
    Itanium-based Systems
  • Windows Server 2003 R2, Datacenter Edition for
    Itanium-based Systems
  • Microsoft Windows Mobile for Pocket PC
  • Windows Mobile for Smartphone
  • Microsoft Windows CE
  • Windows 98
  • Windows 98 Second Edition
  • Windows 2000 Professional with SP4
  • Windows 2000 Server with SP4
  • Windows 2000 Advanced Server with SP4
  • Windows 2000 Datacenter Server with SP4
  • Windows XP Professional with SP2
  • Windows XP Home Edition with SP2
  • Windows XP Media Center Edition 2002 with SP2
  • Windows XP Media Center Edition 2004 with SP2
  • Windows XP Media Center Edition 2005
  • Windows XP Tablet PC Edition with SP2
  • Windows XP Starter Edition
  • Microsoft Windows Millennium Edition
  • Microsoft Windows Server 2003 Standard Edition
  • Windows Server 2003 Enterprise Edition
  • Windows Server 2003 Datacenter Edition
  • Windows Server 2003 Web Edition
  • Windows Server 2003 R2, Standard Edition

25
Windows versions that can not run the .NET
framework v2.0
  • Windows 95
  • Windows NT Server
  • Windows NT Workstation
  • Windows Server 2003, Enterprise Edition for
    Itanium-based Systems
  • Windows Server 2003, Datacenter Edition for
    Itanium-based Systems

26
.NET programming platform
VB
C
C
JScript

Microsoft Intermediate Language
Framework (or Base) Classes
Common Language Runtime
Windows
COM Services
27
5 .NET assemblies and components
28
what is an assembly?
  • one or more .EXE or .DLL files that are versioned
    and deployed as a unit
  • the primary building blocks of a .NET application

29
what is a .NET component?
  • often, by component people really mean dynamic
    link library (DLL file)
  • in .NET, components are often used privately (by
    one application)
  • no registry installation requiredjust copy the
    DLL to the application folder
  • they can be installed in such a way that they can
    be shared (available to any application)

30
the single-file Windows program
  • monolithic application
  • all source code compiled into one .EXE file

APP.exe
31
component-based application
  • component-based application
  • .EXE file one or more .DLL files
  • common on Windows

compute.dll
GUI.exe
data.dll
32
why create separate DLL files?
  • some motivations
  • team programming
  • multi-language development (I like VB.NET, you
    like C)
  • code reuse (e.g., across different .EXEs)
  • independent updating (recompile just one
    component at a time)
  • C and .NET provide good support for
    component-based design
  • develop components
  • interconnect them
  • deploy (install) them
  • version them
  • do all the above over a long period of time
  • need direct compiler and runtime support
  • rather than relying on programming conventions
  • component typically means dynamic link library
    (DLL)

33
assemblies
  • .NET groups application files into assemblies
  • 1 assembly 1 or more compiled classes
  • .EXE represents an assembly with classes Main
    program
  • has an entry point and a user interface
  • .DLL represents an assembly with classes
  • this is just a library its methods must be
    called from an .EXE file

code.vb
code.vb
code.cs
compiler
.EXE or .DLL
assembly
34
where do .NET library DLLs reside on the file
system?
  • framework library assemblies are DLLs which
    reside in a special folder closely guarded by the
    operating system
  • called the Global Assembly Cache (GAC)
  • Windows\Microsoft.NET\Framework
  • gacutil.exe (a utility in the .NET SDK) can used
    to view and modify the contents of the GAC
  • The GAC can hold different versions of the same
    assembly
  • DLLs in the GAC have strong names, versions, and
    digital signatures
  • some GAC assemblies have been pre-compiled into
    native code
  • ngen.exe (a utility in the .NET SDK) can used to
    do this for user DLLs
  • programmers must tell the compiler which .NET
    library assemblies the program will need
  • in VS.NET, you do this by adding a Reference to
    the project
  • (demo)
  • in command-line compilation, you do this with a
    compile switch
  • csc /referencemetad1.dllmetad2.dll
    /outout.exe input.cs

35
where do a programmers DLLs reside on the file
system?
  • private DLLs will usually in same directory as
    our EXE
  • programmers must still tell the compiler about
    any privately developed DLLs the program will
    need
  • in VS.NET, you do this by adding a Reference to
    the project
  • in command-line compilation, you do this with the
    ? switch
  • the .NET runtime will normally search for DLLs
    as follows
  • look first in the GAC
  • then, look in the application folder (where the
    programs .EXE files resides)
  • you can override the runtimes DLL search
    strategy by adding an App.Config file to your
    application at compile time
  • App.Config files are XML and contain extra
    metadata for the runtime

36
terminology review
  • what is an assembly?
  • an .exe or .dll file compiled by a .NET compiler
  • what is metadata?
  • the self-describing information inside a .NET
    assembly
  • What is MSIL?
  • Microsoft Intemediate Language (inside a .NET
    assembly)
  • What is the CLR?
  • Common Language Runtime that executes MSIL code
  • what is managed code?
  • oftware that runs in the CLR
  • what is native code (or unmanaged code)?
  • software than can run on Windows without the CLR

37
what we just covered
  • simplest C program
  • .NET technology overview
  • getting the software you need
  • why Microsoft may have created .NET and C
  • .NET assemblies and components

38
the end of this PowerPoint file
Hooray!
Write a Comment
User Comments (0)
About PowerShow.com