400 likes | 572 Views
Introducing the .NET Framework with C#. New Official Title!. Student Ambassador. Main Entry: am·bas·sa·dor Pronunciation: am-'ba-s&-d&r, &m-, im-, -"dor, -'bas-d&r Function: noun
E N D
New Official Title! Student Ambassador Main Entry: am·bas·sa·dor Pronunciation: am-'ba-s&-d&r, &m-, im-, -"dor, -'bas-d&rFunction: noun 1: an official envoy; especially: a diplomatic agent of the highest rank accredited to a foreign government or sovereign as the resident representative of his own government or sovereign or appointed for a special and often temporary diplomatic assignment 2 a: an authorized representative or messenger b: an unofficial representative <traveling abroad as ambassadors of goodwill>
Why is Microsoft Doing This? • Make Microsoft tools and technology accessible • Provide awareness and training opportunities • To LEARN from student developers
Student Ambassador ProgramRequired Activities • Deliver Tech Talks • 6 Minimum with 30 student attendees per talk • collect & submit evals • Start a .NET User Group • Focused on a specific area of .NET or Microsoft • Support Campus Launch Events • Support Local Field Activities • Drive Awareness of MSDNAA
Student Ambassador ProgramOptional Activities • Host a Student Programming Contest • Student User Group Projects • Limited number of opportunities • Need project proposals ASAP
Defining the .NET Framework • The .NET Framework is • A software development environment • A runtime engine for Managed Code • A platform designed for Internet-Distributed software • The .NET Framework is an exciting new computing platform
What is the .NET Framework • A new computing platform designed to simplify application development • A consistent object-oriented programming environment • A code-execution environment that: • Minimizes software deployment and versioning conflicts • Eliminates the performance problems of scripted or interpreted environments
Primary Components of .NET • .NET Framework Class Libraries • Object-oriented collection of reusable types • Sits on-top of the Common Language Runtime • Common Language Runtime (CLR) • Manages code execution at runtime • Memory management, thread management, etc. • Code designed for the CLR is referred to as “Managed Code”
Inside the .NET Framework VB C++ C# J# Python … ASP.NET High-productivity environment for building and running Web services Web Services User Interface ASP.NET Data and XML Base Framework • Secure, integrated class libraries • Unifies programming models across languages • Enables cross-language integration • Factored for extensibility • Designed for tools Common Language Runtime (CLR) Operating System Common Language Runtime Executes code, maintains security, handles component “plumbing” and dependencies
One Runtime For Many Languages • CLR is an open standard • Any language can make use of CLR services • Any language can use classes written in any other language • Any language can inherit classes written in any other language
.NET Framework Class Libraries • Sit on top of the CLR • Reusable types that tightly integrate with the CLR • Object oriented – inheritance, polymorphism, etc. • Provide functionality for ASP.NET, XML Web Services, ADO.NET, Windows Forms, basic system functionality (IO, XML, etc.)
The Common Language Runtime • Code that targets the CLR is referred to as managed code • All managed code has the features of the CLR • Object Oriented • Cross-language integration • Cross language exception handling • Multiple version support (no more DLL Hell)
The Common Language Runtime • The CLR manages object layout and references to objects • Objects whose lifetimes are managed by the CLR are referred to as Managed Data • Automatic memory management reduces memory leaks • In managed code you can use: • Managed Data • Unmanaged data • Both
The Common Language Runtime • All CLR-compliant compilers use a common type system • Allows for cross-language inheritance • Passing object instances across language barriers • Invoking methods across language barriers • Managed components expose metadata • Metadata includes • Resources component was compiled against • Information about types and dependencies (no more RegServ32
Internet Distributed Software Second-Tier(database or other server) Second-Tier Second-Tier Web Server Web Server Client Client
Managed Code and the CLR • The Common Language Runtime (CLR) is a runtime engine • Manages .NET Code (such as C# applications) • Provides features such as memory management, thread management, object type safety, security, etc. • Is a part of the .NET Framework • Managed code • Code that targets the CLR • Any .NET Language, including C#, Visual Basic, C++, Java, Cobol, etc.
The CLR and Managed Code Legacy Software(unmanaged code) Managed Executable Reusable Managed Components Common Language Runtime(JIT compilation, memory management, etc.) Windows (or other operating oystem)
IL and Metadata • All Managed executables consist of • Intermediate Language (IL) instructions • Metadata • IL • CPU independent machine language • Just-in-time compiled at runtime • Metadata • Structured information • describes programming constructs including • Classes definitions, field and method definitions, parameter lists, return types, etc.
SomeSource.cs using System.Windows.Forms; using System.Drawing; class MyForm:Form{ public static void Main(){ Application.Run( new MyForm()); } protected override void OnPaint( PaintEventArgs e){ e.Graphics.DrawString( "Hello World!", new Font("Arial",35), Brushes.Blue, 10, 100); SomeSources.exe IL Metadata From Source Code to Managed .exe C# Compiler A Managed Application
Just-in-Time Compiling • All managed code runs in native machine language • However, all managed code is made up of IL and metadata • The CLR JIT-compiles the IL and metadata • At execution time • Executed directly by CPU • Allows for the best of both worlds • Code management features • Performance of full-speed execution
SomeSources.exe IL Metadata Executing a Managed Application At execution time the IL and Metadata are JIT compiled Running Process’ Memory JIT Compiler Native Machine Language 10010100 10110000 10000000 10111010 11011011 11010111 11000010 01110110 The CPU executes the JIT- compiled machine code directly
Automatic Memory Management • The CLR manages memory for managed code • All allocations of objects and buffers made from a Managed Heap • Unused objects and buffers are cleaned up automatically through Garbage Collection • Some of the worst bugs in software development are not possible with managed code • Leaked memory or objects • References to freed or non-existent objects • Reading of uninitialized variables • Pointerless environment
Garbage Collection class MyClass{ void Method(){ Variable v1; Variable v2; do{ . . . The Managed Heap B A E C Objects A and D will be cleaned up because neither is directly or indirectly referenced by code D = Object or buffer in memory
Cross Language Support • The .NET Framework supports many languages • Any compiler can be modified to emit managed executables • IL and metadata • Languages that target the .NET Framework • C#, Visual Basic, C++, Java, PERL, COBOL, SmallTalk • Dozens more existing and on the way • Regardless of source language, all managed code can • Use the same tools • Use the same reusable components • Take advantage of features of the CLR • Developers use their language of choice
Visual Studio.NET • A Integrated Development Environment • To develop managed and unmanaged applications • Supports C#, C++, Visual Basic, JavaScript • Many useful tools and wizards • Not part of the .NET Framework • Not necessary to build or run managed code • The .NET Framework SDK includes command line compilers
The Framework Class Library • A huge collection of reusable types • Classes, interfaces, enumerations and structures • For use by any managed code • Including code written in any managed programming language • Types for • Common tasks such as collections, file IO, memory and thread management • GUI and window manipulation • Web form and web service applications • Totally object oriented toolbox for developers • Ships as part of the .NET Framework
Using the FCL • Types are arranged in a hierarchy of Namespaces • A type’s full name includes its namespaces • Form class is actually System.Windows.Forms.Form • Use using to indicate namespaces in source code • Assembly references are necessary for many types • The SDK documentation is critical for using SDK types • Includes descriptions • Often includes useful code samples • Indicates namespaces and assemblies for types
Distributing Managed Code Second-Tier(database or other server) Second-Tier Second-Tier Web Server Web Server Client Client
Language Specific Compiler Managed Execution Process public void Fill() { DotNetJunkies.StudyGroupPortal.Data.EventDB eDB = new DotNetJunkies.StudyGroupPortal.Data.EventDB(); //Create a data reader IDataReader reader = eDB.GetEventByGuid(_guid); //Advance to the first record in the reader reader.Read(); //Populate this instance of the Event class this.CreateEvent(ref reader); //Close the reader reader.Close(); } MSIL
Assembly Language Compiler Compilation And Execution Compilation Code(IL) Source Code Metadata
Microsoft Intermediate Language • Managed code is compiled to MSIL • CPU-independent set of instructions • Loading, storing, initializing and calling methods • Arithmetic and logical operations, etc. • Control flow, exception handling, direct memory access
Assemblies • Contains MSIL code to be executed • Security boundary – permissions are granted at the assembly level • Type boundary – all types include the assembly name they are a part of • Self-describing manifest – metadata that describes the types in the assembly • Smallest versionable unit in the CLR • Deployment unit
Just-In-Time Compiling • Assemblies are compiled to native code by a Just-In-Time (JIT) compiler • Compiled assemblies include metadata • No Type Libraries or Interface Definition Language (IDL)
Assembly Language Compiler Native Code JIT Compiler Execution Compilation And Execution Compilation Code(IL) Source Code Metadata Before installation or the first time each method is called
Just-In-Time Compiling • All assemblies must be compiled to native code before executing • JIT compilers are built into the CLR for every supported CPU architecture • JIT compilers convert MSIL to native on demand • Resulting native code is stored for reuse • JIT compiling occurs for each method after the application is restarted
Summary • .NET Framework is a code execution platform • .NET Framework consists of two primary parts: .NET Class Libraries, Common Language Runtime • All CLR-compliant compilers support the common type system • Managed code is object oriented • Managed code is compiled to and assembly (MSIL) by language specific compiler • Assemblies are compiled to native code by JIT compiler
Contact Information • Alejandro Simon • Talks Web Page: http://asc0.dynup.net/dotnet • E-Mail: asc0_cate@hotmail.com