1 / 39

Introducing the .NET Framework with C#

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

cindy
Download Presentation

Introducing the .NET Framework with C#

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introducing the .NET Framework with C#

  2. 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>

  3. Why is Microsoft Doing This? • Make Microsoft tools and technology accessible • Provide awareness and training opportunities • To LEARN from student developers

  4. Win the hearts and minds of developers

  5. 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

  6. Student Ambassador ProgramOptional Activities • Host a Student Programming Contest • Student User Group Projects • Limited number of opportunities • Need project proposals ASAP

  7. 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

  8. 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

  9. 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”

  10. 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

  11. 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

  12. .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.)

  13. 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)

  14. 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

  15. 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

  16. Internet Distributed Software Second-Tier(database or other server) Second-Tier Second-Tier Web Server Web Server Client Client

  17. 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.

  18. 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)

  19. 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.

  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

  25. 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

  26. 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

  27. 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

  28. 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

  29. Distributing Managed Code Second-Tier(database or other server) Second-Tier Second-Tier Web Server Web Server Client Client

  30. 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

  31. Assembly Language Compiler Compilation And Execution Compilation Code(IL) Source Code Metadata

  32. 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

  33. 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

  34. 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)

  35. 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

  36. 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

  37. 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

  38. Contact Information • Alejandro Simon • Talks Web Page: http://asc0.dynup.net/dotnet • E-Mail: asc0_cate@hotmail.com

  39. Questions?

More Related