Net framework
Upcoming SlideShare
Loading in...5
×
 

Net framework

on

  • 1,287 views

 

Statistics

Views

Total Views
1,287
Views on SlideShare
1,287
Embed Views
0

Actions

Likes
2
Downloads
64
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • The .NET framework exposes numerous classes to the developer. These classes allow the development of rich client applications and Web based applications alike. In the above slide these classes have been divided into 4 areas. ASP.NET provides the core Web infrastructure such as Web Forms for UI based development and Web Services for programmatic interface development, User interface development on the Windows platform can be done using Windows Forms ADO.NET and XML provide the functionality for data access. Finally, the core base classes provide infrastructure services such as security, transaction management etc.
  • We already know that an assembly does NOT contain native binary code, but instead MSIL code. Obviously before the MSIL code can be executed it must be converted into native binary instructions. Converted? Does this mean interpreted? NO! The MSIL code is compiled and not thrown away. This means that next time the code is requested it is already in the form of machine instructions and thus this mechanism in the log run is far more efficient than an interpreter for example. The compilation is carried out by a JIT (Just In Time) compiler. Does the compiler compile all of the code in one go? The answer to this question is NO. If this approach was taken there would be a long delay during the applications initialisation, and realistically not all the code within the module will be required in one go. Instead, when the code is loaded a ‘stub’ is connected to each method. When a method is called via the stub the compiler generates the binary native code. This mechanism goes a long way to describing why the compiler is called a ‘JIT’ compiler. Compiled code is only saved in the same process (run) of an application. And even then it's not guaranteed. we do what's called "code-pitching" which means we through away cold (or little used) JITed code if memory pressure requires it. We do persisted JITed code in the install time scenario. The benefit for to this system is obviously portability. A couple of things to think about - Let’s imagine you’ve built a managed component for the Intel Pentium III platform. It works fine. Later in the year Intel release a super new chip. When Microsoft release a new version of the JIT, it’s possible that this brand spanking new version of the JIT will have learned a few new tricks e.g. to make use of the new improved instruction set of the new Intel chip or new CPU registers! And finally, Microsoft plan to offer a tool called PREJIT. This tool will compile your assemblies into native code and save the resultant binary executable code to disk. When the assemblies are next loaded the binary code is already available thus improving startup time and execution speeds.

Net framework Net framework Presentation Transcript

  • .NET Framework
    • The .NET Framework is an integral Windows component that supports building and running the next generation of applications and XML Web services.
    • Can be described as Development platform or Execution environment which comprises tools and technologies, to develop distributed applications and distributed web services.
    • Microsoft started development on the .NET Framework in the late 1990s originally under the name of Next Generation Windows Services
  • CLI
    • The Common Language Infrastructure (CLI) is an open specification developed by Microsoft and standardized by ISO and ECMA
    • It describes the executable code and runtime environment that form the core of the Microsoft .NET Framework and the free and open source implementations Mono and Portable.NET.
    • The specification defines an environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures.
    • The CLI specification describes the following four aspects:-
    • CTS(Common Type System)
    • Meta data
    • CLS ( Common Language specification)
    • VES( Virtual Execution System)
    • CTS : A set of data types and operations that are shared by all CTS-compliant programming languages.
    • METADATA: It refers to certain data structures embedded within the Common Intermediate Language code that describes the high-level structure of the code.
    • Metadata describes all classes and class members that are defined in the assembly, and the classes and class members that the current assembly will call from another assembly.
    • The metadata for a method contains the complete description of the method, including the class (and the assembly that contains the class), the return type and all of the method parameters.
    • Common Language Specification (CLS)   A set of base rules to which any language targeting the CLI should conform in order to interoperate with other CLS-compliant languages. The CLS rules define a subset of the Common Type System.
    • VES : The VES loads and executes CLI-compatible programs, using the metadata to combine separately generated pieces of code at runtime
    • The .NET Framework is designed to fulfill the following objectives:
    • To provide a consistent object-oriented programming environment whether object code is stored and executed locally, executed locally but Internet-distributed, or executed remotely.
    • To provide a code-execution environment that minimizes software deployment and versioning conflicts.
    • To provide a code-execution environment that promotes safe execution of code, including code created by an unknown or semi-trusted third party.
    • To provide a code-execution environment that eliminates the performance problems of scripted or interpreted environments.
    • To make the developer experience consistent across widely varying types of applications, such as Windows-based applications and Web-based applications.
    • To build all communication on industry standards to ensure that code based on the .NET Framework can integrate with any other code.
  • Features
    • Common Language Runtime Engine – executes all the code
    • Language Independence
    • Base Class Library
    • Simplified Deployment
    • Security
    • Portability
    • Multi-Device Support
    • Automatic memory management
    • No more DLL Hell
  • Advantages
    • The framework is enriched by a common object oriented model. This ensures the developers to do different functionality like database connectivity, file handling and other functionality irrespective of the net programming languages.
    • It supports multiple programming languages and multiple platforms thus allows integration of multiple languages.
    • The GUI interface of this framework is very easy to use so that development time is reduced.
    • Managing the resource for different tasks such as network connection, database resource and usage of these resource are handled by CLR automatically. CLR is releasing the memory
    • (Garbage collection) when the object is not in use automatically.
    • The deployment of the application is very simple. The deployment of the application is using Assemblies which consist of metadata. So it is avoiding the registry problem or DLL hell problem.
    • Reusability of code – The code follows the industry standards, so the framework can be easily integrated with the other code.
    • Security is achieved using Code Access Security Model.
    • Framework is provided with rich debugging support for all types of applications.
    • Framework supports XML which is a major key player in the data exchange between applications.
    • Mobility support
  • Versions
    • Version 1.0 was the first release and was included in the Visual Studio .NET . – add on support for ODBC and Oracle
    • Version 1.1 was released after the first release and Microsoft changed the Visual Studio to Visual studio .NET 2003 with the enhanced features. It was the default framework in Windows Server 2003 – Internet protocol V6 support
    • Version 2.0 was released with the Visual Studio 2005 in the year 2005 – Generics
    • 3.0 was released with the same visual studio of the previous one and was integrated with Windows Vista and Windows Server 2008 – WPF,WCF and WF
    • 3.5 – AJAX - Visual Studio 2008
    • 4.0 – Visual Studio 2010
    • Note : Editions – Notepad file
    • The .NET Framework has three main components:
    • The common language runtime
    • The .NET Framework class library
    • Common Type system
    • The common language runtime is the foundation of the .NET Framework.
    • You can think of the runtime as an agent that manages code at execution time, providing core services such as memory management, thread management, and remoting, while also enforcing strict type safety and other forms of code accuracy that promote security and robustness.
    • In fact, the concept of code management is a fundamental principle of the runtime.
    • Code that targets the runtime is known as managed code, while code that does not target the runtime is known as unmanaged code.
  • CLR
    • The common language runtime manages memory, thread execution, code execution, code safety verification, compilation, and other system services.
    • It is an execution environment for program code defined by CLI.
    • It lies between operating systems and applications written in .NET languages.
    • The runtime enforces code access security
    • The runtime also enforces code robustness by implementing a strict type-and-code-verification infrastructure called the common type system (CTS). The CTS ensures that all managed code is self-describing.
    • Automatic memory management : CLR provides the garbage collection. The objects whose lifetime is managed by the garbage collection are called managed data.
    • The runtime is designed to enhance performance.
    • Platform independence: When you compile a program developed in a language that targets the CLR, the compiler translates the code into an intermediate language is CPU-independent. The code can be executed from any platform that supports the .NET CLR.
    • Security management : It is achieved through the code access Security model. In this, CLR enforces restrictions on managed code through the use of objects called permissions. It specifies what the code can access instead of specifying who can access the resources.
    • Language interoperability: It is the ability of an application
    • to interact with another application written in a different programming language. It helps maximize code reuse.
  • CLR Architecture
    • Different components :
    • Class Loader : The compilers of the framework compile the source code into intermediate code and this code consists of MSIL code and Meta data. These are contained in a portable executable (PE) file. The class loader is loading this data into the run time.
    • Code Manager : This component is managing the above code during execution. This takes the responsibility of allocating memory to the objects also.
    • Garbage collector : This provides automatic garbage collection of the object when the object Is no longer in use. To achieve this, Garbage collector is performing the periodical checks in the heap from where the object gets memory.
    • Security Checker : One of the important components of CLR is security checker. This engine restricts the access to system resources such as hard disk and enforcing the restriction on the MSIL code.
    • Type Checker : This ensures the datatype checking of the variable. This is also checking the valid operations on the corresponding datatype. It means that integer value must be assigned to integer datatype and valid operations are allowed in that type.Otherwise it raises the exception.
    •   Thread support : Multithreading is a very important feature of any programming language. Threads are playing an very important role in developing the application in this framework The application can contain one or more threads. These threads are managed by the CLR.
    • Exception Manager : The Net framework follows the structured exception handling in all its compliant languages.The exception might rise from managed code as well as unmanaged code. This manager provides the support to handle these type of Exceptions.
    •  
    • Debug Engine : Debug means finding and removing the bug from the programs, The application written in any supported framework languages are debugged by this engine.
    • Base class library support – It provides the types that the applications need at run time.
  • CTS(Common Type System)
    • Type refers the datatypes supported by the programming languages.
    • .NET supports the various programming languages. To ensure a free interaction, CTS has been introduced.
    • The specification of CTS defines about the definitions of the type and the values supported by that.
    • CTS is supporting the object oriented concepts thus all types represented in this are objects and also provides support for sharing of common data types.
    • The system allows you to do the language integration. This represents that code in one language can be inherited by the code in another language.
    • 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.
    • 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 Common Language Runtime 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.
    • CTS Supports two different types : Value and reference
    • Value type : Primitive or built in data types of the programming language are Value types. It includes user defined types and enumerations.
    • They are used to store the value of the Variable. This includes String, Character, Integer and other data types. These data types are passed to the method by using by value method.
    • Instances of value types are either allocated on the stack or allocated inline in a structure.
    • Reference Types :Reference types store a reference to the value's memory address, and are allocated on the heap.
    • Reference types 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.
  • CTS
    • Value types : Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in (implemented by the runtime), user-defined, or enumerations.
    • Reference types : Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types 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
  • Class Library
    • The .NET Framework class library is a collection of reusable types that tightly integrate with the common language runtime.
    • The class library is object oriented, providing types from which your own managed code can derive functionality. This not only makes the .NET Framework types easy to use, but also reduces the time associated with learning new features of the .NET Framework.
    • In addition, third-party components can integrate seamlessly with classes in the .NET Framework.
    • We can use the same set of classes for performing a specific task in VB as well as VC++
    • Using these libraries, you can accomplish different tasks such as database connectivity, string handling, input/output functionality, numerical functions and file handling.
    • Library comprises of namespaces and Assemblies
    • The entire library is split into two parts: Base Class Library(BCL) and the Framework Class Library(FCL).
    • Superset of BCL library is called Framework Class library.
    • BCL is a standard library which is available to all languages using the framework.
    • .NET includes the BCL in order to encapsulate a large number of common functions, such as file reading and writing, graphic rendering,database interaction, and XML document manipulation, which makes the programmer's job easier.
    • The Framework Class Library ( FCL ) is a standard library and one of two core components of Microsoft NET Framework. The FCL is a collection of thousands of reusable classes (within hundreds of namespaces), interfaces and value types.
  • The .NET Framework Base Class Library Common Language Specification Common Language Runtime ADO.NET: Data and XML VB C++ C# Visual Studio.NET ASP.NET: Web Services and Web Forms JScript … Windows Forms Windows Forms
  • .NET Framework Libraries
  • Namespaces
    • It helps you to create logical groups of related classes and interfaces that can be used by any language targeting the .NET framework.
    • It allows us to organize the classes so that they can be easily accessed in other applications.
    • It can also be used to avoid name conflicts between classes that have the same names.
    • We can access the classes belonging to a namespace by importing namespace into an application.
    • Framework uses . (dot ) as a delimiter between classes and namespaces.
  • Assemblies
    • An assembly is a single deployable unit that contains all the information about the implementation of classes, structures and interfaces.
    • The new way of packaging the executable code in the .NET framework is Assemblies.
    • It is a self describing unit and all the programs in .net constructed from these assemblies only.
    • It stores all the information about itself.
    • This information is called metadata and includes the name and version number of the assembly, security information, information about the dependencies and a list of the files that constitute the assembly.
    • Namespaces are also stored in assemblies.
    • Assembly Contains the following :
    • Assembly Manifest – Metadata that describes the assembly and its contents
    • Source Code – Compiled into Microsoft intermediate language (MSIL)
    • Type Metadata – Defines all types, their properties and methods, and most importantly, public types exported from this assembly
    • Resources – Icons, images, text strings and other resources
    • Assemblies and metadata provide the CLR with the information required for executing application.
    • Assemblies also play an important role in deployment and versioning.
    • Assemblies can be .DLL or .EXE but they differ in their content.
    • It also consists of assembly metadata known as Assembly Manifest.
    • Every assembly has only one entry point.
    • Information about the assembly version, identity (name), resources needed by the assembly and the scope of the assembly are contained in the manifest file.
    • CLR loads and executes the MSIL code which is in portable executable file only if assembly contains the manifest.
    • Assemblies can be private or shared.
    • Private assembly can be accessible by a single application. On other way, Shared one is shared by multiple application.
    • Depends upon the creation, Assemblies are classified into two namely static and dynamic, Static Assembly is created when we compile our code using compiler.
    • It is stored in the hard disk in the form portable executable file. The dynamic one will be created in the fly during run time and it occupies only memory.
    •   The assembly can be stored in a single file or multiple files.
    • Single file means that the MSIL code, meta data, resources and Assembly metadata all are in single file only.
    • On the other way, they can be separated in different file. That is called multiple file assembly.
    • Assembly linker is used to link all the modules and resource files in the case of multiple structures.
    • Sharing of the assemblies by multiple application is also possible by adding assemblies to the Global Assembly Cache.
    • Metadata is binary information describing your program that is stored either in a common language runtime portable executable (PE) file or in memory.
    • Metadata stores the following information:
    • Description of the assembly.
      • Identity (name, version, culture, public key).
      • The types that are exported.
      • Other assemblies that this assembly depends on.
      • Security permissions needed to run.
    • Description of types.
      • Name, visibility, base class, and interfaces implemented.
      • Members (methods, fields, properties, events, nested types).
    • Attributes.
      • Additional descriptive elements that modify types and members.
  • Assembly Manifest
    • Every assembly, whether static or dynamic, contains a collection of data that describes how the elements in the assembly relate to each other.
    • The assembly manifest contains this assembly metadata.
    • An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes.
    • The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE file that contains only assembly manifest information.
  • Functions
    • Enumerates the files that make up the assembly.
    • Governs how references to the assembly's types and resources map to the files that contain their declarations and implementations.
    • Enumerates other assemblies on which the assembly depends.
    • Provides a level of indirection between consumers of the assembly and the assembly's implementation details.
    • Renders the assembly self-describing .
  • Application Types
    • CLR supports the following type of applications:
    • ASP.NET Web applications: These include dynamic and data driven browser based applications.
    • Windows Form based applications: These refer to traditional rich client applications.
    • Console applications: These refer to traditional DOS kind of applications like batch scripts.
    • Component Libraries: This refers to components that typically encapsulate some business logic.
    • Windows Custom Controls: As with traditional ActiveX controls, you can develop your own windows controls.
    • Web Custom Controls: The concept of custom controls can be extended to web applications allowing code reuse and modularization.
    • Web services: They are “web callable” functionality available via industry standards like HTTP, XML and SOAP.
    • Windows Services: They refer to applications that run as services in the background. They can be configured to start automatically when the system boots up.
  • Memory Management
    • Memory management refers the allocation and releasing of the memory to the object.
    • Developers are supposed to write a code for managing the memory.
    • The programming languages like C++ is using reference count for the allocation and deallocation of the memory.
    • Reference count increases when the memory is allocated for the object and decreases as soon as the object goes out of scope.
    • Developers might fail to decrease the count that leads to memory leak.
    • In the .NET framework, the CLR itself takes care of the memory very efficiently to improve the performance.
    • CLR is following the concept of managed heap.
    • Managed heap means allocation of contiguous address space for the process by the CLR.
    • When the object is created, memory has been allocated to that object from the managed heap by garbage collector and keeps the track of the object when it is in use.
    • For the first object, the pointer is pointing to the base address of the heap.
    • For the second object the memory will be allocated next to the first object.
    • All objects that are allocated consecutively are stored contiguously in the managed heap.
    • So accessing of these objects by the application would be easier. If the memory Is not available, the exception would be raised.
    • When there is no reference to the object or cannot by used by any application, the memory has to be released.
    • GC checks the memory which is not used and marks that as garbage. Then Garbage collector of the framework runs in particular interval and collects the released memory.
    • The resources used by the object have to be released before garbage collection .This can be achieved by writing the code in Dispose method of the object.
    • GC calls the finalize method before the garbage collection. These methods contain the clean up code which are used for releasing the resources.
    • These two are known as finalizers and the process of clean up is called finalization.
    • Dispose method on the object can be called explicitly by the user of the class or during finalization process, the finalize method can call the dispose method.
  • Managed code Execution Process
    • When we compile the code, the code gets translated into MSIL or IL (Microsoft Intermediate language). No matter which language has been used to develop.
    • MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations
    • The compiler also produces the metadata about the program during the process of compilation.
    • Metadata contains the description of the program, the dependencies and the version of the components used in the program.
    • The IL and metadata are linked in an assembly.
    • The compiler creates .EXE or .DLL file.
    • When you execute the .EXE or .DLL file the code and all other relevant information from the base class library is sent to the class loader. This loads the code in the memory.
    • Before the code can be executed, .NET framework needs to convert the IL into native or specific code.
    • The JIT compiler translates the code from IL into managed native code.
    • JIT compiler compiles only the code that is required during execution instead of compiling the complete IL code.
    • When an uncompiled method is invoked during execution, the JIT compiler converts that into native code.
    • During compilation, the code is also checked for type safety.
    • After that, converted code is sent to the .NET runtime manager.
    • .NET runtime manager executes the code. While executing a security check is performed .
  • CLR: Execution Model VB Source code Compiler C++ C# Compiler Compiler Assembly IL Code Assembly IL Code Assembly IL Code Operating System Services Common Language Runtime JIT Compiler Native Code Managed code Unmanaged Component
  • Language interoperability
    • The common language runtime provides the necessary foundation for language interoperability by specifying and enforcing a common type system and by providing metadata.
    • Compilers store type information as metadata, and the common language runtime uses this information to provide services during execution; the runtime can manage the execution of multilanguage applications because all type information is stored and retrieved in the same way, regardless of the language the code was written in.
    • Managed code benefits from the runtime's support for language interoperability in the following ways:
    • Types can inherit implementation from other types, pass objects to another type's methods, and call methods defined on other types, regardless of the language the types are implemented in.
    • Debuggers, profilers, or other tools are required to understand only one environment — the Microsoft intermediate language (MSIL) and metadata for the common language runtime — and they can support any programming language that targets the runtime.
    • Exception handling is consistent across languages. Your code can throw an exception in one language and that exception can be caught and understood by an object written in another language.
  • Code Access Security
    • Code access security is a mechanism that helps limit the access code has to protected resources and operations. In the .NET Framework, code access security performs the following functions:
    • Defines permissions and permission sets that represent the right to access various system resources.
    • Enables administrators to configure security policy by associating sets of permissions with groups of code (code groups).
    • Enables code to request the permissions it requires in order to run, as well as the permissions that would be useful to have, and specifies which permissions the code must never have.
    • Grants permissions to each assembly that is loaded, based on the permissions requested by the code and on the operations permitted by security policy.
    • Enables code to demand that its callers have specific permissions.
    • Enables code to demand that its callers possess a digital signature, thus allowing only callers from a particular organization or site to call the protected code.
    • Enforces restrictions on code at run time by comparing the granted permissions of every caller on the call stack to the permissions that callers must have.
    • To determine whether code is authorized to access a resource or perform an operation, the runtime's security system walks the call stack, comparing the granted permissions of each caller to the permission being demanded.
    • If any caller in the call stack does not have the demanded permission, a security exception is thrown and access is refused.
  • Advantages
    • Consistent programming model: It provides a common object oriented programming model across languages. This can be used in code to perform several tasks such as reading and writing to file, connecting to the database and retrieving data
    • Multilanguage Integration: .NET allows multiple languages to be integrated. It is possible to create a class in C# that derives from a class implemented in Visual Basic. It has CLS (Common Language Specification) includes the basic language features required by many applications.
    • Most of the classes are CLS compliant.
    • Automatic Resource management :CLR automatically tracks resource usage and relieves a programmer of the task of manual resource management.
    • Ease of deployment : .NET applications can be deployed simply by copying files to the computer. In the .NET framework ,applications are deployed in the form of assemblies. Assembly stores metadata. Therefore registry entries are not required for storing information about components and application.
    • Mobility Support
    • XML Web service Support
    • Flexible Data Access
    • COM Interoperability : You can maintain your existing code without the need to recode. COM interoperability enables you to leverage your existing code assets and offers seamless bi-directional communication between Visual Basic 6.0 and Visual Basic .NET applications
  • Alternate
    • Mono is an up-to-date implementation of the CLI and the .NET Base Class Library (BCL), and provides additional functionality.
    • It is dual-licensed under free software and proprietary software licenses
    • It runs on several operating systems, including various flavors of Linux and Mac OS
    • It includes support for ASP.NET, ADO.NET, and Windows Forms libraries for a wide range of architectures and operating systems.
    • It also includes C# and VB.NET compilers.
    • Portable.NET (part of DotGNU) provides an implementation of the Common Language Infrastructure (CLI), portions of the .NET Base Class Library (BCL), and a C# compiler.
    • It supports a variety of CPUs and operating systems.