200 likes | 251 Views
C# IDE and Tools. Yingcai Xiao. (1) IDE: all-in-one programming tools (2) Includes: editor, compiler, linker, loader, debugger, profiler, project organizer, context-sensitive help, form designer, programming code libraries, application framework templates, …
E N D
C#IDE and Tools Yingcai Xiao
(1) IDE: all-in-one programming tools (2) Includes: editor, compiler, linker, loader, debugger, profiler, project organizer, context-sensitive help, form designer, programming code libraries, application framework templates, … (3) IDE you may have used: Eclipse, jGRASP, NetBeans, BlueJ (4) Microsoft IDEs: MS Visual Studio 6.0: last non .NET version. MS Visual Studio 7.0 => MS Visual Studio .NET MS Visual Studio 8.0 => MS Visual Studio .NET 2005 MS Visual Studio .NET 20xx Start->All Programs->Microsoft Visual Studio 20xx-> Microsoft Visual Studio 20xx Documentation Integrated Development Environment (IDE)
Create your first C# program Setup: • If you are on a CS computer, refer to the following link to setup the Z drive. http://www.cs.uakron.edu/~xiao/lab-use.html • Use C drive if you have problem mounting the Z drive. Remember to copy your code to a flash drive and delete your work on the C drive before logging out from the CS computer. • Use C drive if you are on a home computer. • In the following examples, replace drive letter Z with C if you are using the C drive.
(1) Create a project Start->All Programs->Microsoft Visual Studio 20xx-> Microsoft Visual Studio 20xx Start Page -> New Projects Visual C#->Windows->Console Application Name: Hello Solution name: Hello Location: Browse Folders->Computer->Z->WP (New Folder) -> Select Folder (Default on winserv1: C:\users\xiaotest\documents\visual studio 20xx\Projects) OK (2) Code System.Console.WriteLine ("Hello, world!"); System.Console.WriteLine ("Hit any key to end."); System.Console.Read(); (3) Run F5 (Debug->Start Debugging) Z:\WP\Hello\bin\Debug\bin Create your first C# program using Visual Studio .NET
(1) Project setting: Set project to “Debug” (default setting) DEBUG->Start Debugging (2) Break points left-click on the left frame of the source window to set a break point. (3) Watch right-click on a variable select Add to Watch (4) Windows Watch window Output window for debugging Console window for the running program Debugging
z:\WP\Hello ( the solution directory) Hello.sln (solution info) Hello (project directory, there can be more than one project) z:\WP\Hello->Hello ( the project directory) Program.cs (the C# source file) Hello.csproj (C# project info) App.config (Application configuration) bin (directory for the executables to be delivered) obj (directory for the object files, working directory) Properties (AssemblyInfo.cs) VS Project Directory
z:\WP\Hello->Hello->bin (directory for the executables to be delivered) Release->Hello.exe (the non-debugable executable, smaller) Debug->Hello.exe (the debugable executable, larger) Debug->vshost.exe (VS hosting process for debugging) z:\WP\Hello->Hello->obj (directory for .obj and other temp files) Release->Hello.obj (the non-debugable obj, smaller) Debug->Hello.obj (the debugable obj, larger) Debug->TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92 (VS hosting process for debugging) VS Project Directory
Create the same program using Notepad (1) Edit (create the source code using Notepad) Start->All Programs->Microsoft Visual Studio 20xx->Visual Studio Tools->Microsoft Visual Studio Command Prompt (20xx) Z: mkdir WP cd WP mkdir Hello2 cd Hello2 notepad Hello.cs & (background process) Copy code from the next page. (2) Compile (using the C-Sharp Compiler) csc /target:exe /out:Hello.exe Hello.cs (csc Hello.cs) (3)Excute Hello.exe
Create the same program using Notepad namespace Xiao { class MyApp { static void Main () { System.Console.WriteLine ("Hello, world"); System.Console.WriteLine ("Hit any key to end."); System.Console.Read(); // Don’t call “exit”. Why? } } }
.NET Programming Examples http://www.cs.uakron.edu/%7Exiao/windows/Examples.zip
FCL (.NET framework class library): object-oriented API for writing managed applications more than 7,000 classes in named spaces: e.g. System.Windows.Forms, System.IO stored as DLLs (Dynamically Linked Libraries). http://msdn.microsoft.com/en-us/library/w0x726c2(v=vs.110).aspx CLR (common language runtime): execution engine for managed applications. Inside .NET Programs: FCL & CLR
Source Code for Language 1 Source Code for Language 2 Language 1 Compiler on OS1 Language 2 Compiler on OS2 MSIL Code Confirming CTS (Managed Code) CLR on OS1 .NET Architecture for Language and Platform Independence (fan-in and fan-out on MSIL) CLR on OS2 Binary Code for OS1 Binary Code for OS2 OS1 OS2
Managed Code: application code whose every action is subject to approval by the CLR (common language runtime) and its compiler conforms to the CLS (common language specification) and supports the CTS (common type system). • Unmanaged Code: native machine code that runs without CLR. • Advantages of running managed code through CLR: Type safe (type checked by CLR at runtime) Light weight (multiple applications per process) Garbage collection Managed and Unmanaged Code
Contents of a managed module: • CIL instructions generated from the source code • Metadata describing code inside the module • A CLR header containing important information about the module • A Windows Portable Executable (PE) file header • Metadata: a collection of tables that describe the code. • TypeDef • Class Names • Assembly: is a collection of one or more files (modules) grouped together to form a logical unit. Manifest: metadata for an assembly. Name, version, data types exported. • AL (Assembly Linker): joins files into assemblies. Module/Metadata-Assembly/Manifest
Reflection: runtime understanding of the code (data types, program organizations, …) • Reflection APIs: programming tools in System.Reflection namespace to read metadata. • ILDASM: a program in .NET SDK to view the metadata using the reflection APIs • DIA SDK: Debug Interface Access SDK The Microsoft Debug Interface Access Software Development Kit (DIA SDK) providesaccess to debug information stored in program database (.pdb) files (http://msdn.microsoft.com/library/en-us/diasdk/html/vsoriDebugInterfaceAccessSDK.asp) Reflection