SlideShare una empresa de Scribd logo
1 de 28
Introducing the .NET Framework with C#   Global Computer Center
Assemblies  Assemblies are the physical packaging of the class libraries. These are .dll files, but don't confuse them with Win32 shared libraries. Examples are  mscorlib.dll  System.dll  System.Data.dll  Accessibility.dll Note that namespaces are often distributed among several assemblies
Defining the .NET Framework ,[object Object],[object Object],[object Object],[object Object],[object Object]
Internet Distributed Software Web Server Client Client Web Server Second-Tier (database or  other server) Second-Tier Second-Tier
A First Look at Managed Code 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); } } HelloGUI.cs c:gt; csc /target:winexe HelloGui.cs
Demo HelloGUI.cs
Managed Code and the CLR ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The CLR and Managed Code Windows  (or other operating oystem) Common Language Runtime (JIT compilation, memory management, etc.) Legacy  Software (unmanaged code) Managed Executable Reusable  Managed Components
IL and Metadata ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
From Source Code to Managed .exe C# Compiler A Managed  Application This Cod is  output with  Manifest Into a PE (Portably Executable ) File 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); SomeSource.cs SomeSources.exe IL Metadata
Just-in-Time Compiling ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Executing a Managed Application Running Process’ Memory JIT Compiler 10010100 10110000 10000000 10111010 11011011 11010111 11000010 01110110 Native  Machine Language The CPU executes the JIT- compiled machine code directly At execution time the IL and  Metadata are JIT compiled SomeSources.exe IL Metadata
Automatic Memory Management ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Garbage Collection A B E D C The Managed Heap = Object or buffer in memory class MyClass{ void Method(){ Variable v1; Variable v2; do{ . . .  Objects  A  and  D  will be cleaned up because neither is directly or indirectly referenced by code
Cross Language Support ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Visual Studio.NET ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Demo Visual Studio.NET
The Framework Class Library ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using the FCL ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Demo The FCL SDK
Types of Managed Applications ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Distributing Managed Code Web Server Client Client Web Server Second-Tier (database or  other server) Second-Tier Second-Tier
Demo Draw.aspx
Introducing the .NET Framework with C#
 
Class Library  The class library provides a comprehensive set of facilities for application development. Primarily written in C#, it can be used by any language, thanks to the Common Language Specification .  The class library is structured into Namespaces, and deployed in shared libraries known as Assemblies. When we speak of the .NET framework , we are primarily referring to this class library.
Namespaces  Namespaces are a mechanism for logically grouping similar classes into a hierarchical structure. This prevents naming conflicts. The structure is implemented using dot-separated words. The top level namespace for most of the .NET framework is System . Under the System namespace you'll find the following:  System.IO  System.Net  System.Net.Sockets  System.Reflection  System.Threading  ...and many others. There are other top-level namespaces as well; Accessibility , and Windows are examples. You can also create your own namespaces: just prefix them with the name of your organization. Microsoft.VisualBasic is an example.
Common Language Specification (CLS): 1)The Common Language Specification (CLS) describes a set of features that different languages have in common. The CLS includes a subset of the Common Type System (CTS).  2)The CTS makes available a common set of data types so that compiled code of one language could easily interoperate with compiled code of another language by understanding each others’ data types.  3)The common type system is a rich type system, built into the common language runtime, that supports the types and operations found in most programming languages. The common type system supports the complete implementation of a wide range of programming languages. 4)common type system this is used to communicate with other language. example in vb we have int and in c++ we have long so that in one case they are not compatiable with each other so that CTS palys important role with using System.int32

Más contenido relacionado

La actualidad más candente

Introductionto .netframework by Priyanka Pinglikar
Introductionto .netframework by Priyanka PinglikarIntroductionto .netframework by Priyanka Pinglikar
Introductionto .netframework by Priyanka PinglikarPriyankaPinglikar
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra SolutionsQUONTRASOLUTIONS
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsQuontra Solutions
 
Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net FundamentalsLiquidHub
 
.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligetiNaveen Kumar Veligeti
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net frameworkArun Prasad
 
Module 1: Introduction to .NET Framework 3.5 (Slides)
Module 1: Introduction to .NET Framework 3.5 (Slides)Module 1: Introduction to .NET Framework 3.5 (Slides)
Module 1: Introduction to .NET Framework 3.5 (Slides)Mohamed Saleh
 
Lesson 1 Understanding Dot Net Framework
Lesson 1   Understanding Dot Net FrameworkLesson 1   Understanding Dot Net Framework
Lesson 1 Understanding Dot Net Frameworknbaveja
 
Introduction to .NET Programming
Introduction to .NET ProgrammingIntroduction to .NET Programming
Introduction to .NET ProgrammingKarthikeyan Mkr
 
.Net framework architecture
.Net framework architecture.Net framework architecture
.Net framework architectureFad Zulkifli
 
The .NET Platform - A Brief Overview
The .NET Platform - A Brief OverviewThe .NET Platform - A Brief Overview
The .NET Platform - A Brief OverviewCarlos Lopes
 
.Net framework
.Net framework.Net framework
.Net frameworkRaghu nath
 
Welcome to the .Net
Welcome to the .NetWelcome to the .Net
Welcome to the .NetAmr Shawky
 
6.origins genesis of .net technology
6.origins genesis of .net technology6.origins genesis of .net technology
6.origins genesis of .net technologyPramod Rathore
 
.Net platform an understanding
.Net platform an understanding.Net platform an understanding
.Net platform an understandingBinu Bhasuran
 

La actualidad más candente (20)

Introductionto .netframework by Priyanka Pinglikar
Introductionto .netframework by Priyanka PinglikarIntroductionto .netframework by Priyanka Pinglikar
Introductionto .netframework by Priyanka Pinglikar
 
Microsoft.Net
Microsoft.NetMicrosoft.Net
Microsoft.Net
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutions
 
Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net Fundamentals
 
.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti.Net framework components by naveen kumar veligeti
.Net framework components by naveen kumar veligeti
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
Net framework
Net frameworkNet framework
Net framework
 
.Net
.Net.Net
.Net
 
Module 1: Introduction to .NET Framework 3.5 (Slides)
Module 1: Introduction to .NET Framework 3.5 (Slides)Module 1: Introduction to .NET Framework 3.5 (Slides)
Module 1: Introduction to .NET Framework 3.5 (Slides)
 
.Net slid
.Net slid.Net slid
.Net slid
 
Lesson 1 Understanding Dot Net Framework
Lesson 1   Understanding Dot Net FrameworkLesson 1   Understanding Dot Net Framework
Lesson 1 Understanding Dot Net Framework
 
Introduction to .NET Programming
Introduction to .NET ProgrammingIntroduction to .NET Programming
Introduction to .NET Programming
 
.Net framework architecture
.Net framework architecture.Net framework architecture
.Net framework architecture
 
The .NET Platform - A Brief Overview
The .NET Platform - A Brief OverviewThe .NET Platform - A Brief Overview
The .NET Platform - A Brief Overview
 
.Net framework
.Net framework.Net framework
.Net framework
 
Dot net
Dot netDot net
Dot net
 
Welcome to the .Net
Welcome to the .NetWelcome to the .Net
Welcome to the .Net
 
6.origins genesis of .net technology
6.origins genesis of .net technology6.origins genesis of .net technology
6.origins genesis of .net technology
 
.Net platform an understanding
.Net platform an understanding.Net platform an understanding
.Net platform an understanding
 

Destacado

Socket programming in C#
Socket programming in C#Socket programming in C#
Socket programming in C#Nang Luc Vu
 
Visual Studio Enterprise 2015 Overview atidan
Visual Studio Enterprise 2015 Overview   atidanVisual Studio Enterprise 2015 Overview   atidan
Visual Studio Enterprise 2015 Overview atidanDavid J Rosenthal
 
2CPP11 - Method Overloading
2CPP11 - Method Overloading2CPP11 - Method Overloading
2CPP11 - Method OverloadingMichael Heron
 
c#.Net Windows application
c#.Net Windows application c#.Net Windows application
c#.Net Windows application veera
 
The Psychology of C# Analysis
The Psychology of C# AnalysisThe Psychology of C# Analysis
The Psychology of C# AnalysisCoverity
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Xamarin
 
Microsoft Dynamics NAV 2013 R2 Overview and NAV Roadmap
Microsoft Dynamics NAV 2013 R2 Overview and NAV RoadmapMicrosoft Dynamics NAV 2013 R2 Overview and NAV Roadmap
Microsoft Dynamics NAV 2013 R2 Overview and NAV RoadmapSociusPartner
 

Destacado (9)

Socket programming in C#
Socket programming in C#Socket programming in C#
Socket programming in C#
 
Visual Studio Enterprise 2015 Overview atidan
Visual Studio Enterprise 2015 Overview   atidanVisual Studio Enterprise 2015 Overview   atidan
Visual Studio Enterprise 2015 Overview atidan
 
2CPP11 - Method Overloading
2CPP11 - Method Overloading2CPP11 - Method Overloading
2CPP11 - Method Overloading
 
c#.Net Windows application
c#.Net Windows application c#.Net Windows application
c#.Net Windows application
 
C# simplified
C#  simplifiedC#  simplified
C# simplified
 
The Psychology of C# Analysis
The Psychology of C# AnalysisThe Psychology of C# Analysis
The Psychology of C# Analysis
 
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
Intro to Xamarin for Visual Studio: Native iOS, Android, and Windows Apps in C#
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
Microsoft Dynamics NAV 2013 R2 Overview and NAV Roadmap
Microsoft Dynamics NAV 2013 R2 Overview and NAV RoadmapMicrosoft Dynamics NAV 2013 R2 Overview and NAV Roadmap
Microsoft Dynamics NAV 2013 R2 Overview and NAV Roadmap
 

Similar a Intro.net

Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishSvetlin Nakov
 
Session2 (3)
Session2 (3)Session2 (3)
Session2 (3)DrUjwala1
 
Chapter1_Part1.pptx
Chapter1_Part1.pptxChapter1_Part1.pptx
Chapter1_Part1.pptxRaajzKoirala
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net frameworkFaisal Aziz
 
.Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1).Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1)Rishi Kothari
 
Presentation1
Presentation1Presentation1
Presentation1kpkcsc
 
Net framework
Net frameworkNet framework
Net frameworkjhsri
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - IntroductionRandy Connolly
 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qaabcxyzqaz
 
Dot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part iDot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part iRakesh Joshi
 
Dot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part iDot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part iRakesh Joshi
 

Similar a Intro.net (20)

Nakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - EnglishNakov - .NET Framework Overview - English
Nakov - .NET Framework Overview - English
 
Session2 (3)
Session2 (3)Session2 (3)
Session2 (3)
 
Vb
VbVb
Vb
 
.Net framework
.Net framework.Net framework
.Net framework
 
Visual studio
Visual studioVisual studio
Visual studio
 
Chapter1_Part1.pptx
Chapter1_Part1.pptxChapter1_Part1.pptx
Chapter1_Part1.pptx
 
c#.pptx
c#.pptxc#.pptx
c#.pptx
 
Net framework
 Net framework Net framework
Net framework
 
Inside .net framework
Inside .net frameworkInside .net framework
Inside .net framework
 
.Net overview
.Net overview.Net overview
.Net overview
 
.Net Overview
.Net Overview.Net Overview
.Net Overview
 
.Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1).Net Overview -- Training (Lesson 1)
.Net Overview -- Training (Lesson 1)
 
Presentation1
Presentation1Presentation1
Presentation1
 
Net framework
Net frameworkNet framework
Net framework
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
 
Dotnet interview qa
Dotnet interview qaDotnet interview qa
Dotnet interview qa
 
Dot Net PPt.pptx
Dot Net PPt.pptxDot Net PPt.pptx
Dot Net PPt.pptx
 
.Net Session Overview
.Net Session Overview.Net Session Overview
.Net Session Overview
 
Dot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part iDot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part i
 
Dot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part iDot net-interview-questions-and-answers part i
Dot net-interview-questions-and-answers part i
 

Intro.net

  • 1. Introducing the .NET Framework with C# Global Computer Center
  • 2. Assemblies Assemblies are the physical packaging of the class libraries. These are .dll files, but don't confuse them with Win32 shared libraries. Examples are mscorlib.dll System.dll System.Data.dll Accessibility.dll Note that namespaces are often distributed among several assemblies
  • 3.
  • 4. Internet Distributed Software Web Server Client Client Web Server Second-Tier (database or other server) Second-Tier Second-Tier
  • 5. A First Look at Managed Code 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); } } HelloGUI.cs c:gt; csc /target:winexe HelloGui.cs
  • 7.
  • 8. The CLR and Managed Code Windows (or other operating oystem) Common Language Runtime (JIT compilation, memory management, etc.) Legacy Software (unmanaged code) Managed Executable Reusable Managed Components
  • 9.
  • 10. From Source Code to Managed .exe C# Compiler A Managed Application This Cod is output with Manifest Into a PE (Portably Executable ) File 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); SomeSource.cs SomeSources.exe IL Metadata
  • 11.
  • 12. Executing a Managed Application Running Process’ Memory JIT Compiler 10010100 10110000 10000000 10111010 11011011 11010111 11000010 01110110 Native Machine Language The CPU executes the JIT- compiled machine code directly At execution time the IL and Metadata are JIT compiled SomeSources.exe IL Metadata
  • 13.
  • 14. Garbage Collection A B E D C The Managed Heap = Object or buffer in memory class MyClass{ void Method(){ Variable v1; Variable v2; do{ . . . Objects A and D will be cleaned up because neither is directly or indirectly referenced by code
  • 15.
  • 16.
  • 18.
  • 19.
  • 21.
  • 22. Distributing Managed Code Web Server Client Client Web Server Second-Tier (database or other server) Second-Tier Second-Tier
  • 24. Introducing the .NET Framework with C#
  • 25.  
  • 26. Class Library The class library provides a comprehensive set of facilities for application development. Primarily written in C#, it can be used by any language, thanks to the Common Language Specification . The class library is structured into Namespaces, and deployed in shared libraries known as Assemblies. When we speak of the .NET framework , we are primarily referring to this class library.
  • 27. Namespaces Namespaces are a mechanism for logically grouping similar classes into a hierarchical structure. This prevents naming conflicts. The structure is implemented using dot-separated words. The top level namespace for most of the .NET framework is System . Under the System namespace you'll find the following: System.IO System.Net System.Net.Sockets System.Reflection System.Threading ...and many others. There are other top-level namespaces as well; Accessibility , and Windows are examples. You can also create your own namespaces: just prefix them with the name of your organization. Microsoft.VisualBasic is an example.
  • 28. Common Language Specification (CLS): 1)The Common Language Specification (CLS) describes a set of features that different languages have in common. The CLS includes a subset of the Common Type System (CTS). 2)The CTS makes available a common set of data types so that compiled code of one language could easily interoperate with compiled code of another language by understanding each others’ data types. 3)The common type system is a rich type system, built into the common language runtime, that supports the types and operations found in most programming languages. The common type system supports the complete implementation of a wide range of programming languages. 4)common type system this is used to communicate with other language. example in vb we have int and in c++ we have long so that in one case they are not compatiable with each other so that CTS palys important role with using System.int32

Notas del editor

  1. Sample Dialog: Speaker Instructions: You should introduce yourself on this slide. Briefly address the topic of the evening and mention the length of the presentation. You can also discuss the nature of your organization (user group, etc.) while on this slide.
  2. Sample Dialog: The .NET Framework is a new computing platform developed by Microsoft. It can be somewhat difficult to describe, because it plays a number of roles. It is a software development environment and SDK. It is a runtime environment for executable code, and it is a platform with many features of an OS. C# and other languages can be used to target the .NET Framework, and the .NET Framework as a platform is designed to target the Internet.
  3. Sample Dialog: The common Internet software of today includes a client which communicates with a web server. The client is most likely running a browser or some other standard client such as an FTP client. The Server is running any of a number of server products to serve the client. Moving forward, the lines of communication will open up. Second and third tiers will communicate directly with clients. Clients will communicate with each other in a pier-to-pier relationship, and servers across realm and company boundaries will also communicate on a pier-to-pier bases. The nature of the communication itself will also expand. At this time most communication is either HTML over HTTP or HTTPS, or it is proprietary. However, moving forward, SOAP and XML will allow for more flexible communication between parties. Traditionally, writing software that runs on the client (typical applications, as well as client applications) is vastly different from writing server or back-end server programs. The tools and languages differ, as well as the libraries and reusable code. This makes programming for the Internet difficult and often inefficient. The .NET Framework is built from the ground up to target each level shown on this slide. Meanwhile the language, libraries, and tools you prefer can be used for client and server tasks. Speaker Instructions: There is a lot of sample dialog on this slide you can pick which points you wish to make. The last sentence is important though.
  4. Sample Dialog: Before digging too deeply into what the .NET Framework is and does, I would like to show a little C# code. C# is only one of the languages that you can use to write .NET programs, however it is one of the most popular. Speaker Instructions: Consider bringing up this source code in an editor. Either way, walk through the code. Point out the class definition as well as the main function. Point out that this code has a C-based syntax much like Java or C++. Point out the use of preexisting types such as Application and Form. On the next slide you should compile and run the code, and perhaps briefly explain how it works.
  5. Sample Dialog: Now I am going to compile and run the C# program from the last slide. As you can see it is a simple “Hello World” GUI application… Speaker Instructions: You can use Visual Studio or the command line compiler here to run this code. You should explain how the code works. Point out that this is an example of a managed application, and that you will define that term in more detail shortly. The source code for HelloGUI.cs is included as a Visual Studio.NET with this module.
  6. Sample Dialog: The .NET Framework is made up of several parts. One of the most important pieces of the framework is the Common Language Runtime or CLR. The CLR is a runtime engine that manages .NET code as it is running. Management includes security management, memory management, thread management and a host of other system services. For this reason all code targeting the .NET Framework (including C# code) is called Managed Code There are a number of language compilers that produce managed executable files. C# is a popular language, but you can use Java, Visual Basic, C++, Cobol, PERL, etc. Speaker Instructions: It is important that the reader understand that what is true of managed code is true across all languages that can be managed. The cross language abilities of the .NET Framework are a big win for programmers. This is why it is helpful to refer to executables and modules as managed executables and managed modules, rather than always saying C# executables (since C# is a specific language).
  7. Sample Dialog: You can see here the relationchip between your managed executable, the CLR, and the underlying operating system. The CLR runs on Windows (and other operating systems in the future). Managed code runs on the CLR, and makes use of reuseable object libraries (often managed as well). Legacy or unmanaged software runs along-side managed code. Speaker Instructions: Managed code is not interpreted. This slide can give that impression. It is important to note that this is not the case, and emphasize it later on when we cover JIT compiling.
  8. Sample Dialog: What makes a managed executable managed is the fact that it is made up of IL instructions and metadata. IL stands for Intermediate Language, and is a “CPU independent assembly language.” Managed code logic is represented as IL rather than x86 machine language instructions. Metadata is also an important part of managed code. In fact, a managed EXE would not be manageable without its metadata. The metadata describes everything that can’t be described by IL. That is to say that metadata describes everything but the executable logic. This includes class definitions, method definitions, parameter types and return types. Between metadata and IL, the CLR has enough information about your managed code to insure type-safety at all times. Speaker Instructions: The type safety issue is an important one as code modules become increasingly distributed over the Internet. It might be a bit much to attempt to relay this in an hour session.
  9. Sample Dialog: So if you look at this diagram, you can see that you start with a C# source file (this could be any .NET language), and then compile it. What the compiler produces is an .EXE file that contains Metadata and IL (always in the same file). This is a managed executable. Note that IL is not C#, and by the time your software is in binary form it has no relationship to its source language. Speaker Instructions: This last point is an important first step in understanding the language agnosticism of the .NET Framework. Language agnosticism is a major improvement over Java. If anybody asks if IL is basically another name for p-code say, “yes and no”. Here are the facts. IL is programming language agnostic, where p-code is typically tied to a language. IL builds on the good parts of p-code, but moves forward. Another difference is that IL is always JIT compiled, and executed in native machine language, where p-code is often interpreted. By the way, just FYI, Sun did not create p-code. P-code has existed long before Java. There were p-code Pascal compilers in the 70’s. (You don’t have to bring this up unless you are pressed by someone who thinks that IL is just a stolen idea).
  10. Sample Dialog: One great thing about managed code is that it is NOT interpreted. ALL managed code runs in native machine language, even though it is represented as CPU independent IL. This is possible, because at runtime the CLR Just-In-Time compiles (or JIT compiles) the IL into native code, and then it executes the code. This really does allow for the best of both worlds between code interpretation and the performance of native machine language. Speaker Instructions: JIT compiling is a cool feature, and you should feel comfortable with the concepts behind it before presenting in class. There are often a number of questions on this topic. The tutorial goes into JIT compilation in some detail.
  11. Sample Dialog: When a user executes a managed application, the system immediate loads the CLR unto the new processes. The CLR then begins JIT compiling the IL from the executable and executing it. It is not necessary for every IL instruction in an executable to be JIT compiled before it is run. This happens as needed. Once the code is running, it is run directly by the CPU. However, the JIT compiler emits code that insures that your program remains manageable by the CLR. So even though the code is running native, it is always managed code. Speaker Instructions: The notion of managed code running in native machine language can be tough to comprehend. But the point is that it is IL until the point of running. It is the CLR that creates the machine language, so it has all of the control necessary to maintain the managed status of the software.
  12. Sample Dialog: One very important aspect that the CLR manages for your .NET code is memory management. All memory allocations come from a Managed Heap. Your code never explicitly frees memory. Once memory is no longer referenced by your software it is eligible for Garbage Collection. Although memory management can be a fun part of computer programming, it is important for managed code to allow the system to manage memory, because moving forward many applications will be comprised of objects developed elsewhere and distributed across the internet. Since we can’t trust these objects to have boundless access to memory, it is important that memory is managed. Additionally, so very painful and common memory bugs are impossible with managed code. Speaker Instructions: Often there are questions about performance related to the Garbage Collector. Here are some facts. Garbage collection takes time but happens rarely Meanwhile, managed heap allocations are MUCH faster than a malloc or new in C++ Memory fragmentation is impossible with the managed heap, so memory is used MUCH more efficiently with the managed heap.
  13. Sample Dialog: Garbage collection can happen at any time that your program needs memory. It typically happens in response to a “new” operation. When a garbage collection occurs, garbage objects and memory buffers are removed from the managed heap. In this example, if a garbage collection were to occur during the execution of the Method() method, objects A and D would be cleaned up, because they are not referenced by code, nor are they referenced by objects that are referenced by code. Speaker Instructions: The arrows pointing from one object to the next in the managed heap indicate fields in objects that refer to other objects in the managed heap. The arrows pointing from the source code to the heap indicate reference variables on the stack in your running code, that refer to objects in the managed heap.
  14. Sample Dialog: Because managed code is IL and metadata, it is possible for any compiler to be modified to produce managed code. All it needs to do is produce an EXE comprised of IL and Metadata, and now the exe can run with the CLR. There are many languages already in existence or in development that target the .NET Framework. The advantage is that programmers can use their language of choice while being able to use the same tools and code libraries as any other managed code. Speaker Instructions:
  15. Sample Dialog: Visual Studio.NET is not part of the .NET Framework, however it is a great development environment for building .NET code. You can use the command-line compilers that come with the .NET Framework to build managed code, however Visual Studio.NET includes useful wizards and tools that the .NET Framework does not ship with. It is important to distinguish between Visual Studio and the .NET Framework. The .NET Framework is a platform (and an SDK). Visual Studio is an Integrated Development Environment that targets the platform that is the .NET Framework. Speaker Instructions: Visual Studio costs money, the .NET Framework is free.
  16. Sample Dialog: Speaker Instructions: You should bring up Visual Studio.NET and create a C# windowed project. Drag and drop a button or two onto the form, and then build and run the application. Show the code that was produced by the designer. Point out that this code could be written from scratch, but that Visual Studio makes the development process much easier.
  17. Sample Dialog: The CLR is object oriented through and through. So is C#. You will find that you make use of reusable object libraries a lot when writing managed code. The Framework Class Library (or FCL) is a huge object library that ships with the .NET Framework. It has many classes, interfaces, and structures (collectively called “types”), that help you do a number of common and advanced programming tasks. Familiarity with the FCL is critically important for a .NET developer. You will find classes in the FCL for creating and manipulating files, collection classes, windowing and GUI programming, web-sight development and hundreds more. Additionally, the FCL is built for extension, so it is common to write software that derives from classes in the FCL to extend their features. Speaker Instructions: The lines between applications and components will become much blurrier. This important in the evolution of the software industry in general.
  18. Sample Dialog: Types in the FCL are arranged in a hierarchy of namespaces. It is helpful to be familiar with the namespaces, so that you can find related types more easily. A types full name includes its namespace. So in your code you may refer to a type named “Form”, however the CLR will always think of the type as System.Windows.Forms.Form, where System.Windows.Forms is the type’s namespace. Types are also published in files called assemblies. The sdk documentation indicates a types namespace and assembly. The namespace should be added to the top of your source module (if you are using the type) with a “using” statement. The assembly for a type should be added to your project references when building the program. Speaker Instructions: Become comfortable with assembly references and the using statement before presenting this slide. You will most likely get questions. The Visual Studio.NET IDE allows you to add references to your project. These references are assemblies, and the appropriate assembly to choose depends on the types that you are using in your sources.
  19. Sample Dialog: Speaker Instructions: You should bring up the help topic for System.Windows.Forms.Form and walk through the different parts of the help. You can use the topic in the tutorial as a guideline for what parts to show in the help. The MOST important parts are the namespace and assembly items near the bottom of the help. But it is also useful to point out the sample code and other information in the topic.
  20. Sample Dialog: Now that we have discussed the .NET Framework in general, it is good to cover what you can do with it. First of all, you can write typical applications. These are your standard GUI or console applications that run on the users machine. More importantly, however, managed code and the FCL are designed to promote Internet distributed code. This includes web-pages that run as software on the server side. This also includes web-services which are a non GUI server-side object. Web-servers can distribute managed objects to be executed locally on the client. In this respect, managed code can run just about anywhere, and makes for some very interesting application design possibilities. Finally, the CLR can be hosted in any application. This makes it possible to use managed code as the script or macro language for your program. Meanwhile, wherever managed code runs, it is always language agnostic, JIT compiled and executed natively, and it always has full access to the FCL. Speaker Instructions: The win here is that when you get comfortable writing any kind of C# application you can apply those skills to more advanced or vastly different types of applications. No more learning a whole net set of “stuff” just because your application is a different kind of application.
  21. Sample Dialog: So now we can take a look at the distributed code slide, and apply our knowledge of managed code. If you are writing a client component, then your managed program is likely to using Windows.Forms for GUI and the FCL classes for communicating with servers. Client code can also be hosted in a browser. If you are writing web server code, then the CLR is hosted in a server product like IIS and you are probably writing Web Forms or Web Services code. Your software is still C# or VB or whatever language you choose, but now it runs with all of the services of a high-scalability web-server. Finally, second tier servers like data-base servers can host managed code. Managed code can be used as stored procedures or just about any logic in an application that hosts the CLR. The benefit is that you get to use tools, languages, and code that you are already comfortable with. Speaker Instructions: This is a repeat of the slide found earlier in the deck. When presenting this slide, you should point to a client box, and describe the kinds of managed code that runs there. Then the web-server, then the second tier. This helps round out the user’s understanding.
  22. Sample Dialog: In closing I would like to demo a simple Web Forms application. This application runs on the server side, and is hosted in IIS. Any browser can be used to browse to this application. (It does not need to be running on Windows). Speaker Instructions: You should browse to the Draw.aspx file and show how the application works. Then you should show the source code for the application. Point out that the website is implemented using C# like any other application. If you have time, run through the logic of the code. Point out to the user that the code comes with the tutorial and they can try it themselves. Also point out that Web Forms are an advanced topic and that an entire session is devoted to the topic.
  23. Sample Dialog: Speaker Instructions: Open the floor to questions