49
.Net Technology 171604 (IT) Advanced .Net Technology 170707 (CE)

Net Technology 171604 (IT) Advanced .Net Technology (CE) · Managed Extensibility Framework (MEF) 3. Dynamic Language Runtime (DLR) 4. Task Parallel Library.NetFramework Version

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

.Net Technology 171604 (IT)

Advanced .Net Technology170707 (CE)

Text Books

1. Professional VB. NET,  Wrox Pub.

2. ASP .NET Complete Reference, TMH Pub.

3. C# The Basic by Vijay Mukhi

Reference Books

1. ASP.NET Developer’s Guide – Greg Buczek, MGH Pub.

2. Programming VB.Net 2005, Julia Case Bradley, Anita Millspaugh, MGH Pub.

3. ASP.NET 2.0  Black Book, Dreamtech Pub.

4. ASP.NET 4  Unleashed – Stephen Walther, Kevin Hoffman, Nate Dudek, Pearson Pub.

5. Professional C#.Net, Wrox Pub.

Course Contents

• Introduction to .NET

• Data Types and Base Class Libraries

• VB .NET

• Object Oriented Programming with VB.NET

• Introduction to Windows Forms

• Windows Forms and Controls in detail

• Introduction to ADO.NET

• Console Applications

• C# .NET

Course Contents

• ASP.Net

• Managing State

• Themes and Master Pages

• Using the Data Bound controls and Repeater Controls

• Creating and Consuming Web Services

• Advance .Net Concepts

Visual Studio .NET

• Integrated Development Environment

• Supports  many languages for developing software  e.x.  VB, VISUAL C++, Visual C# etc

• Used to develop projects such as Web application

Windows Form Application

Console Application.

Mobile Application

Web services.

What is .NET Framework?

• .NET framework is a platform or an environment  created by Microsoft  for developing Windows and Web based application.

• It is a framework, which offers new Object Oriented programming paradigm. 

• Is a layer between the operating system and the programming language 

• .NET Framework consists of 2 main parts:Common Language Runtime(CLR)Framework Class Library(FCL)

Features of .NET

• Object Oriented Programming Environment

• In built Memory Management

• Support Multiple  Language  and Cross Language Integration 

• NET provides a common set of class libraries, which can be accessed from any .net based programming language. 

• XML support

visual studio .net supports for writing, manipulating and transferring XML documents.

.Net Framework Version .Net

VersionIDE Features

4.5.1 Visual Studio 2013 1. Includes performance and debugging improvements 

2. Support for automatic binding redirection 3. Expanded support for Windows Store apps

4.5  Visual Studio 2012 1. Features Enhancements to CLR 4.02. Async Support3. Support for building Windows Store apps4. Features Enhancement to WPF, WCF, WF, and 

ASP.NET

4.0  Visual Studio 2010 1. Introduced CLR 4.0 2. Managed Extensibility Framework (MEF)3. Dynamic Language Runtime (DLR)4. Task Parallel Library

.Net Framework Version .Net

VersionIDE Features

3.5  Visual Studio 2008  1. Built‐In AJAX Support 2. LINQ3. Dynamic Data4. Multi‐targeting Framework Support

3.0  Visual Studio 2005 1. Windows Presentation Foundation (WPF)2. Windows Communications Foundation (WCF)3. Windows Workflow Foundation (WF), and 

CardSpace

2.0  Visual Studio 2005 1. Introduced CLR 2.0 2. Generics and generic collections3. Partial classes4. Nullable types5. Anonymous methods6. Introduced many new controls and features to 

ASP.NET

.Net Framework Version .Net

VersionIDE Features

1.1  Visual Studio .NET 2003

1. Features Enhancement to ASP.NET and ADO.NET

2. Built‐in support for mobile ASP.NET controls3. Security Enhancement4. Built‐in support for ODBC and databases5. Internet Protocol version 6 (IPv6) support

1.0  Visual Studio .NET 1. Introduced CLR 1.02. Support for Object‐oriented Web application 

development3. Use of DLL class libraries

.Net Framework Stack

.NET Framework ‐ Architecture 

Overview of the .NET architecture

.NET Framework 4.5 Architecture 

Common Language Runtime (CLR)

Flow Chart of CLR execution model

Features of CLR

• Memory Management

• Assembly Loading

• Security

• Exception Handling

• Thread Synchronization

Managed Module (CLR)

• It is either 32 bit or 64 bit Microsoft StandardPortable Executable File Format required by CLR toexecute.

• All languages outputs PE 32 or PE32+ format filesand that will get executed by CLR to produce CPUinstructions.

Managed Module (CLR)

The above diagram describes why .Net frameworks are so called Languageindependent and it is due to CLR. As CLR is common for all languages.

Components of Managed Module (CLR)

Components of Managed Module (CLR)PE32 or PE32 + Header

• PE 32 – Runs on version 32bit or 64 bit  of Windows• PE 32+ – Runs on only version 64 bit  of Windows• Header contains information about type of the file i.eDLL, GIF etc.

• Header contains information about time stamp that when file built.

• If the managed module is having only IL then PE 32 (+) header is ignored by CLR.

• If the managed module contains CPU Instructions then PE 32 (+) header contains information about CPU instructions.

Components of Managed Module (CLR)

CLR Header• This contains the information interpreted by CLR.• This contains information about version of CLR needed to interpret the managed module.

• This contains Flags information.• CLR header contains MethodOF token which says what is entry point (main method) of managed module.

IL Code• Code generated by language compiler as compiled outputs. This IL code gets interpreted by CLR to produce CPU instructions.

Components of Managed Module (CLR)

MetaData• Meta Data is set of tables that contain all the information about what defines in the module.

• Two types of Meta Data table– Table describes  type and members in code

– Table describes  type and members reference in code

• Meta Data is always associated with the files contain the IL. 

• Meta Data packaged in the same dll or exe file.

Uses of Meta Data table• Meta Data removes the natives' code like header files.

• Visual Studio uses Meta Data to perform work of IntelliSense. IntelliSense feature of visual studio uses Meta data tables to give suggestion while writing codes.

• CLR code verification uses Meta Data tables to make sure code only performs type safe operations.

• Meta Data performs work of serialization and deserialization.

• Garbage collector reads life time of object from Meta data table.

Components of Managed Module (CLR)

CLR services• Assembly Resolver 

• Assembly Loader 

• Type Checker 

• COM marshaller

• Debug Manager 

• Thread Support 

• IL to Native compiler 

• Exception Manager 

• Garbage Collector

CLR servicesAssembly Resolver

– It will read manifest of application– it will identify private and shared assembly required for application execution 

– the request will be send to assembly loader.

Assembly Loader – It will load assembly into application process based on assembly resolver instructions.

Type Checker– It will verify types used in the application with CTS or CLS standards supported by CLR, this provides type safety.

CLR servicesCOM marshaller

– It will provide communication with COM component, this supports COM interoperability.

Debug Manager– It will activate debugger utility to support line by line execution , the developer can make changes as per requirement without terminating application execution.

Thread Support– It will manage more than one execution path in application process. This provides multithreading support.

CLR servicesIL to Native compiler

– IL to native compiler is called JIT compiler(just‐in‐time compiler) , this will convert IL code into operating System native code.

Exception Manager– It will handle exceptions thrown by application by executing catch block provided by exception, if there is no catch block , it will terminate application.

Garbage Collector– It will release memory of unused objects, this provides automatic memory management.

Benefits CLR• Performance improvements• The ability to easily use components developed in other languages

• Extensible types provided by a class library.• Language features such as inheritance, interfaces, and overloading for object‐oriented programming.

• Support for explicit free threading that allows creation of multithreaded, scalable applications.

• Support for structured exception handling.• Support for custom attributes.• Garbage collection.• Use of delegates instead of function pointers for increased type safety and security. 

Common Type System (CTS)• CTS is a rich type system, built into the CLR, that supports the types and operations found in most programming languages.

• CTS supports the complete implementation of a wide range of programming languages. 

• CTS defines how types are declared, used, and managed in the CLR.

• CTS is also an important part of the runtime's support for cross‐language integration. 

Functions of CTS• To establish a framework that helps enable cross‐language integration, type safety, and high performance code execution.

• To provide an object‐oriented model that supports the complete implementation of many programming languages.

• To define rules that languages must follow, which helps ensure that objects written in different languages can interact with each other.

• The CTS also defines the rules that ensures that the data types of objects written in various languages are able to interact with each other.

Functions of CTS

• The CTS also specifies the rules for type visibility and access to the members of a type, i.e. the CTS establishes the rules by which assemblies form scope for a type, and the CLR enforces the visibility rules.

• The CTS defines the rules governing type inheritance virtual methods and object lifetime.

• Languages supported by .NET can implement all or some common data types

• It is used to communicate with other languages

CTS Type Categories

• Value types: – directly contain their data

– instances of value types are either allocated on the stack  or allocated inline in a structure. 

– can be built‐in, user‐defined, or enumerations.

– inherit directly from a type called ValueType, which in turn inherits from Object.

– the types in this category include Byte, Char, signed integers of various lengths, unsigned integers of various lengths, single‐ and double‐precision floating point, Decimal, Boolean etc.

CTS Type Categories• Reference types:

– store a reference to the value's memory address– are allocated on the heap – it can be self‐describing types, pointer types, or interface types. 

– the type of a reference type can be determined from values of self‐describing types. Self‐describing types are further split into arrays and class types. The class types are user‐defined classes, boxed value types, and delegates.

– it directly from Object– the types in this category include Class, Interface, Array, String and Delegate

CTS Type Categories

The CTS defines reference and value types, all of which inherit from a common Object type.

CTS Type Categories

Instances of value types ‐ allocated on the managed stack,  instances of reference types ‐ allocated on the managed heap

Common Language Specification (CLS)• CLS is a subset of the CTS. 

• CLS is actually a set of restrictions on the CTS. 

• CLS defines not only the types allowed in external calls, but the rules for using them, depending on the goal of the user. 

• CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow.

• CLS is a set of basic language features (constructs and constraints) that serves as a guide for library writers and compiler writers. 

Common Language Specification (CLS)• CLS includes calling virtual methods, overloading methods and does not include things such as unsigned types. 

• CLS is weighted very heavily in favor of the library designers

• MS has defined three level of CLS compatibility / compliance

– Compliant producer

– Consumer

– Extender

Assembly• It is a collection of types and resources that forms a logical unit of functionality

• When you compile an application, the MSIL code created is stored in an assembly

• Assembly is the smallest unit of deployment of a .netapplication. 

• It can be a dll (use by other applications) or an exe. (run directly from Windows)

• There are two kind of assemblies in .NET– private – Shared– Satellite

Assembly• Private Assembly:

– The dll or exe which is sole property of one application only. 

– It is generally stored in application root folder

• Public/Shared assembly:– It is a dll which can be used by multiple applications at a time. 

– A shared assembly is stored in GAC (Global Assembly Cache) 

– GAC is simply C:\Windows\Assembly folder where you can find the public assemblies/dll of all the software installed in your PC.

Managed Code Execution Process

Unmanaged Code• The code, which is developed outside .NET, Framework is known as unmanaged code. 

• Applications that do not run under the control of the CLR are said to be unmanaged. Languages such as C++ can be used to write such applications, which access low ‐ level functions of the operating system. Background compatibility with code of VB, ASP and COM are examples of unmanaged code.

• Unmanaged code is executed with help of wrapper classes.

• Wrapper classes are of two types: CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper)

COM Callable Wrapper unmanaged code

Runtime Callable Wrapper unmanaged code

Native CodeThe code to be executed must be converted into a language that the target operating system understands, known as native code.

MSIL (Microsoft Intermediate Language)

It is language independent code.

JIT (Just‐in‐Time)Just ‐ in ‐ Time (JIT) compiler, which compiles MSIL into native 

code that is specific to the OS and machine architecture being targeted.

• Garbage Collection (GC)

One of the most important features of managed code is the concept of garbage collection. This is the .NET method of making sure that the memory used by an application is freed 

up completely when the application is no longer in use.

Major problem before .net• Regiatration of COM components (Component Object Model) 

COM is used by developers to create re‐usable software 

components.COM is an interface standard for software introduced by 

Microsoft in 1993 and it is used to enable inter process  communication and dynamic object creation in programming language

COM is used in applications For example COM OLE technology allows Word documents to dynamically link to data in Excel spreadsheets .

• Unloading COM Components.(free up memory when it is no longer to use)

• Versioning problem (DLL hell)

DLL Hell problem

• "DLL Hell" refers to the set of problems caused when multiple applications attempt to share a common component like a dynamic link library (DLL) or a Component Object Model (COM) class.

• The reason for this issue was that the version information about the different components of an application was not recorded by the system. (Windows Registry cannot support the multiple versions of same COM component this is called the dll hell problem.)