Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Module Overview
Introduction to the .NET Framework 4 Creating Projects Within Visual Studio 2010
Writing a C# Application
Building a Graphical Application Documenting an Application
What Is an Assembly?
How the Common Language Runtime Loads, Compiles,
Class Library
Development Frameworks
What Is an Assembly?
Building blocks of .NET Framework applications Collection of types and resources that form a logical unit of functionality
Assembly version
<major>.<minor>.<build>.<revision>
How the Common Language Runtime Loads, Compiles, and Runs Assemblies
Assemblies contain MSIL code, which is not actually executable
The CLR loads the MSIL code from an assembly and converts it into the machine code that the computer requires
1 2
Loads assemblies that the application references Verifies and compiles assemblies into machine code Runs the executable assembly
Caspol.exe
Makecert.exe
Gacutil.exe
Ngen.exe
Ildasm.exe
Sn.exe
Assembly
WPF Application
Class Library Windows Forms Application ASP.NET Web Application
.xaml.cs .config
.config
1 2
In Visual Studio 2010, on the Build menu, click Build Solution On the Debug menu, click Start Debugging
Command line
Open Ildasm
Disassemble an existing .NET Framework assembly Examine the disassembled .NET Framework assembly
Application
System.IO namespace
File class FileInfo class Path class
DirectoryInfo class
Directory class
Bring System namespace into scope using System; Namespace declaration namespace MyFirstApplication { class Program Program class declaration { static void Main(string[] args) { } } } Main method declaration
Read()
ReadKey() ReadLine() Write() WriteLine()
// This is a comment on a separate line. string message = "Hello there!"; // This is an inline comment.
What Is WPF?
WPF is a new foundation for building Windows-based applications by combining:
Features of WPF
Media
Documents
Use of XAML
ComboBox
TextBox
Grid
Button example: <Button Name="myButton" BorderBrush="Black" BorderThickness="1" Click="myButtonOnClick" ClickMode="Press"> Click Me </Button>
WPF Events
Using WPF, you create event-driven applications, for example, responding to a button being clicked, item selections, and so on
Button definition
<Button Name="myButton" Click="myButton_Click">ClickMe</Button>
Event handler
private void myButton_Click(object sender, RoutedEventArgs e) { // Code to do something goes here. }
1
2 3 4
Create a new WPF application Add controls to the WPF application Set control properties Add event handlers to controls Add code to implement business logic
/// <summary> The Hello class prints a greeting on the screen /// </summary> public class Hello { /// <summary> We use console-based I/O. For more information /// about /// WriteLine, see <seealso cref="System.Console.WriteLine"/> /// </summary> public static void Main( ) { Console.WriteLine("Hello World"); } }
Start Debugging
Break All
Using Breakpoints
When you run an application in Debug mode, you can pause execution and enter break mode
Step over the current statement Step out of the current statement
Logon information
Lab Scenario
Lab Review
Review Questions
What methods did you use to capture and display
What event did you handle on the Format Data button in What debugging functions did you use when you verified
the application?
Tools