770 likes | 778 Views
Learn the philosophy of .NET and the building blocks of the .NET framework. Explore topics like CTS, CLR, CLS, CIL, and metadata.
E N D
Subject Name: C# PROGRAMMING AND .NET CONCEPTS Subject Code: 10CS761 Prepared By: Suganthi Sivakumar Department: CSE Date
C# PROGRAMMING AND .NET CONCEPTS UNIT-I Engineered for Tomorrow C# PROGRAMMING AND .NET CONCEPTS - UNIT I
THE PHILOSOPHY OF .NET Engineered for Tomorrow C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Learning Outcomes • The idea of Building blocks of .NET, .NET base class libraries, CTS, CLR, CLS, CIL& Metadata, Assembly Manifest, Namespaces will be obtained.
Topic details • Introduction • Previous State of Affairs • Building blocks of .NET • .NET base class libraries • CTS • CLR • CLS • CIL& Metadata • Assembly Manifest • Namespaces
1.1INTRODUCTION Engineered for Tomorrow 1.1.1 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 • 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 C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.1.2 Components of .NET • .NET Framework Class Libraries • Common Language Runtime (CLR) 1.1.3 .NET Framework Class Libraries • Provide functionality for ASP.NET, XML Web Services, ADO.NET, Windows Forms, basic system functionality • Reusable types that tightly integrate with the CLR • Sit on top of the CLR C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.1.4 Common Language Runtime(CLR) • 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 • Objects whose lifetimes are managed by the CLR are referred to as Managed Data • Automatic memory management reduces memory leaks • 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 C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.1.5 Intermediate Language • CPU independent machine language • Just-in-time compiled at runtime 1.1.6 Metadata • Structured information • Describes programming constructs including Classes definitions, field and method definitions, parameter lists, return types, etc 1.1.7 Just-In-Time compiler • The CLR JIT-compiles the IL and metadata • At execution time • Executed directly by CPU C# PROGRAMMING AND .NET CONCEPTS - UNIT I
1.2 PREVIOUS STATE OF AFFAIRS Engineered for Tomorrow • Life As a C/Win32 API Programmer • Life As a C++/MFC Programmer • Life As a Visual Basic 6.0 Programmer • Life As a Java/J2EE Programmer • Life As a COM Developer • Life As a Windows DNA Programmer C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.2.1 Life As a C/Win32 API Programmer • Terse language • It is complex • Not an Object Oriented Language • Manual memory management 1.2.2 Life As a C++/MFC Programmer • C++ with MFC is still complex and error prone • Root is C 1.2.3 Life As a Visual Basic 6.0 Programmer • Doesn’t support inheritance • No Multithreading • Low level API calls are complex C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.2.4 Life As a Java/J2EE Programmer • Not suitable for graphic intensive problems • No cross Language Integration support 1.2.5 Life As a COM Developer • Complex creation of COM Types • Location Transparent nature • can be accessed in language independent manner • Reusable binary code 1.2.6 Life As a Windows DNA Programmer • It is complex • Requires use of numerous technologies and languages C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.3 THE .NET SOLUTION 1.3.1 Features provided by .NET • Full interoperability with existing code • Complete and total language integration • Common runtime engine shared by all .NET aware languages • Base class library • No more COM Plumbing • Truly simplified deployment model C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.4 Building Blocks of .NET Platform C++ C# VB J# … Visual Studio.NET Python Common Language Specification Web Services User Interface ASP.NET Data and XML Base Class Library Common Language Runtime (CLR) Operating System C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.4.1 CLR(Common Language Runtime) • Code management at program execution • Provides memory management, thread management, security management, code verification, compilation services • Supports cross language integration, cross language exception handling, deployment support, debugging 1.4.2 CTS(Common Type System) • Defines how types are declared, used and managed in the runtime 1.4.3 CLS(Common Language Specification) • A set of rules that defines a subset of types and specifications C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.5 THE ROLE OF BASE CLASS LIBRARIES The Base Class Library Data Access Windows Forms Security XML/SOAP (et al.) Web Forms Threading File I/O The Common Language Runtime Common Type System Common Language Specification C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.6 WHAT C# BRINGS TO THE TABLE • No pointers required • Automatic memory management through garbage collection • Supports operator overloading • Ability to build generic types and generic members • Supports enumerations, structures • Supports interface based programming languages C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.7Overview of .NET Assemblies • After compilation of program in .NET, the resulting file is called Assembly • Assembly contains additional information that .NET framework will use • It contains manifest 1.7.1 Manifest • Set of metadata • Contains information about assembly itself • It contains name, version, list of files of an assembly C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.7.2 Role of CIL • CIL sits above a specific compiler • The associated compiler emits CIL instructions and stored in assembly • Assembly is stores in PE format(.dll or .exe) 1.7.3 Role of .NET Type Metadata • CLR generates metadata during compilation & stores in assembly • Allows to write component in c# C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.8 The Role of Assembly Manifest 1.8.1 Single file assemblies • Contains CIL, Metadata & Manifest in a single well defined package 1.8.2 Multifile Assemblies • Composed of modules • One of the module must contain Assembly manifest C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.9 Compiling CIL to Platform specific instructions 1.9.1 Just-In-Time Compiler • Compiles CIL instructions into corresponding machine code • Also called as jitter C# PROGRAMMING AND .NET CONCEPTS - UNIT I
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); Metadata IL SomeSources.exe Engineered for Tomorrow 1.9.2 From Source Code to Managed .exe C# Compiler A Managed Application C# PROGRAMMING AND .NET CONCEPTS - UNIT I
SomeSources.exe IL Metadata Engineered for Tomorrow 1.9.3 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 C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Assembly Language Compiler Native Code JIT Compiler Execution Engineered for Tomorrow 1.9.4 Compilation And Execution Code(IL) Source Code Metadata Compilation Before installation or the first time each method is called C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.10 Understanding the common type system • Specifies how type definitions and specific values of types are presented in memory • Allow programs written in different languages to share information easily • Defines rules that languages must follow • Provides object oriented model • Establishes a framework to enable cross language integration, type safety CTS Structure Types • Derived from a common base class System.TypeValue C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow CTS class types • Contains methods, properties, events etc • Multiple inheritance is allowed CTS Enumeration Type • To group name/value pairs under a specific name CTS Interface Type • Same As Pure Abstract class in C++ • Similar to class, but never instantiated CTS Delegate Type • Same as C’s Function pointer C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.11 Intrinsic CTS Data Types C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.12 Understanding Common Language Specification • Set of guidelines that describe the minimal and complete set of features a given .NET aware compiler must support • C# allows operator overloading VB .NET does not • The void functions may differ in syntax: VB .NETC# public Sub Foo() public void Foo() ……………………. {………………..} End Sub C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.12.1 CLS Compilance C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.13 Common Language Runtime(CLR) .NET Compiler .NET Source Code DLL or EXE(CIL) mscoree.dll .NET Execution Engine Class Loader Base Class Libraries (mscorlib.dll) Jitter Platform specific code Execute C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow • 1.14 .NET Namespaces • System is the root namespace • Example • using System; • public class MyApp • { • public static void Main() • { • Console.WriteLine(“Welcome to C#”); • } • } C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow 1.14.1 Sample .NET namespaces C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Summary • The Building blocks of .NET, .NET base class libraries, CTS, CLR, CLS, CIL& Metadata, Assembly Manifest, Namespaces are discussed. C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow Question Bank 1)Explain the CLR. Illustrate the workflow that takes place between the source code, given .NET compiler and the .NET execution engine. 2)Explain the complexities found in the technologies prior to .NET. Briefly describe. Explain how .NET attempts to simply the same 3)Justify “ How The .NET Framework is a Radical and Brute- Force’ 4)List and explain the intrinsic CTS data types and .NET namespaces in C#. 5) a)Briefly explain how the history of .NET. 6)Explain the building components of .NET and their responsibilities. C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow Question Bank 7)Explain Jitter. Along with its benefits. 8)Explain how CLR host an application on .NET platforms. Give the block diagram. 9)What is an assembly? Explain each component of an assembly. 10)Differentiate between single file and multi file assembly. 11)What is .NET assembly? What does it contain? Explain each of them. 12) Write a note on .NET namespaces. C# PROGRAMMING AND .NET CONCEPTS - UNIT I
Engineered for Tomorrow THANK YOU C# PROGRAMMING AND .NET CONCEPTS - UNIT I
C# PROGRAMMING AND .NET CONCEPTS UNIT-II Engineered for Tomorrow C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Building C# Applications Engineered for Tomorrow C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Learning Outcomes • The idea of command line compiler, response files, code debugger, bug reports generation, pre processor directives, system Environment class will be obtained
Topic details Engineered for Tomorrow • csc.exe • csc.rsp • cordbg.exe • Remaining c# compiler options • Visual studio .NET IDE • Other key aspects • Documenting source code via XML • C# preprocessor Directives • System Environment class C# PROGRAMMING AND .NET CONCEPTS - UNIT II
2.1 The role of the command Line compiler (csc.exe) Engineered for Tomorrow C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Example Engineered for Tomorrow using System; class MainClass { public static void Main() { Console.WriteLine("A simple C# program."); } } To Compile: csc MainClass.cs C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow • 2.1.1 Rules for Command line Syntax for the c# compiler • Arguments are delimited by white space, which is either a space or a tab • The caret character (^) is not recognized as an escape character or delimiter. The character is handled by the command-line parser in the operating system before it is passed to the argv array in the program • A string enclosed in double quotation marks ("string") is interpreted as a single argument, regardless of white space that is contained within. A quoted string can be embedded in an argument • A double quotation mark preceded by a backslash (\") is interpreted as a literal double quotation mark character (") C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow • Backslashes are interpreted literally, unless they immediately precede a double quotation mark • If an even number of backslashes is followed by a double quotation mark, one backslash is put in the argv array for every pair of backslashes, and the double quotation mark is interpreted as a string delimiter • If an odd number of backslashes is followed by a double quotation mark, one backslash is put in the argv array for every pair of backslashes, and the double quotation mark is "escaped" by the remaining backslash. This causes a literal double quotation mark (") to be added in argv C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow 2.2.1 Categories of Flags provided by csc.exe C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow 2.2.2 Input-centric options of csc.exe C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow 2.2.3 Output-centric options of csc.exe C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow • 2.2.4 Variations of the /target flag C# PROGRAMMING AND .NET CONCEPTS - UNIT II
Engineered for Tomorrow • 2.3 Working with csc.exe Response files • Contain all of the options you want to feed into csc.exe • Used to build MyCodeLibrary.dll • csc @MyCodeLibraryArgs.rsp • To specify multiple response files: • csc @MyCodeLibraryArgs.rsp @MoreArgs.rsp @EvenMoreArgs.rsp • Response files are processed in the order they are encountered C# PROGRAMMING AND .NET CONCEPTS - UNIT II