Académique Documents
Professionnel Documents
Culture Documents
The .NET Framework consists of the following components: Common Language Runtime .NET Framework class library ADO.NET: data and XML ASP.NET Common Language Runtime The Common Language Runtime (CLR) simplifies application development, provides a robust and secure execution environment, supports multiple languages, and simplifies application deployment and management. The environment is also referred to as a managed environment, one in which common services, such as garbage collection and security, are automatically provided. .NET Framework Class Library The .NET Framework provides a unified, object-oriented, hierarchical, extensible set of class libraries (APIs) for developers to use. Previously, C++ developers used the Microsoft Foundation Classes. Visual Basic developers used classes provided by the Visual Basic runtime. Other languages used their own class libraries and frameworks. Simply put, the .NET Framework unifies the disparate frameworks Microsoft previously provided. As a result, developers no longer have to understand multiple frameworks to do their work. But more than that, by creating a common set of APIs across all programming languages, the .NET Framework enables cross-language inheritance, error handling, and debugging. In effect, all programming languages, from JScript to C++, become equals, and developers are free to choose the language that they want to use. ADO.NET: Data and XML ADO.NET is the next generation of ActiveX Data Object (ADO) technology. ADO.NET is tightly integrated with XML, allowing developers to transfer datasets (in-memory data caches) between the various components of an enterprise solution.
ASP.NET builds on the programming classes of the .NET Framework, thereby providing a Web application model in the form of a set of controls and infrastructure that make it simple to build Web applications. Developers have access to a rich set of ASP.NET Web controls that encapsulate common Hypertext Markup Language (HTML) user interface features such as text boxes, drop-down menus, and so on. These controls actually run on the Web server and simply project their user interface as HTML to a browser. On the server, the controls expose an object-oriented programming model that brings the power of object-oriented programming to the Web developer. ASP.NET also provides infrastructure services, such as session state management and process recycling, that further reduce the amount of code a developer must write and that increase application reliability. ASP.NET also uses these same concepts to enable developers to deliver software as a service. By using XML Web services, developers can simply write their business logic, and the ASP.NET infrastructure will be responsible for delivering that service through the SOAP protocol. Assemblies and Metadata The base unit of a .NET-based application is called an assembly. An assembly is the unit of versioning and deployment. Typically, you compile your source code into an EXE or a DLL (you can also create modules, which can later be linked into an EXE or a DLL). These are the simplest forms of an assembly. Compilers generate assemblies containing Microsoft Intermediate Language. Apart from the MSIL code, however, the compiler inserts metadata into the assembly. Metadata is a collection of information that describes all of the types, classes, methods, fields, events, and more contained within the assembly. This is somewhat like the idea of a type library. However, unlike a COM server that may or may not have a type library resource embedded in it, an assembly and its metadata are inseparable. This, of course, means that the assembly is self-describing. Single-File and Multifile Assemblies In many cases, an assembly could be thought of as a single EXE or DLL. In some situations, a single assembly makes deployment much simpler, since all the required components are bundled together. However, a number of assemblies (for example, DLLs) can be linked together in one assembly (a multifile assembly). To achieve this you use the Assembly Linker tool, AL.EXE. In some situations, for example in Web based applications, the fact that assemblies are contained within separate files can be a great advantage, since only those modules that are required can be downloaded. The CLR Execution Model Before the MSIL code can be executed, it must be converted into native binary instructions. The compilation is typically carried out by a JIT compiler. The following diagram illustrates the process used to compile and execute managed code - that is, code that uses the CLR.
Source code written in C#, Visual Basic .NET, or some other language that targets the CLR is first transformed into MSIL by the appropriate language compiler. Before execution, this MSIL code is compiled into native code by a JIT compiler for whatever processor the code will run on. The JIT compiler does not compile the entire code at one time. The default is to JIT compile each method when it is first called, but it's also possible to "pre-JIT" the IL code using the Native Image Generator (NGEN.EXE). With this option, all methods are compiled before the application is loaded, so the overhead of JIT compilation on each initial method call is avoided. Note that all languages targeting the CLR should exhibit roughly the same performance. While some compilers may produce better MSIL code than others, large variations in execution speed are unlikely.
2) Main components of .NET framework: a) Common Language Runtime. b) .NET Framework class Library. 3) CLR: - 1) Environment that manages code execution 2) Provides core services such as a) Code Compilation b) Memory allocation c) Thread Management d) Garbage collection 3) Common Type System (CTS) , enforces strict type safety, and it ensures that code is executed in a safe environment by enforcing code access security. 4) Is designed for cross-language compatibility.
Component
Description
Class loader
Microsoft Intermediate Language Converts MSIL to native (MSIL) to native compilers Generation (NGEN)).
Native
Code manager
Provides automatic lifetime management of all of your objects. The garbage collector is multithreaded and scalable.
Security engine
Provides evidence-based security, based on the origin of the code in addition to the identity of the invoking code.
Debug engine
Allows you to debug your application and trace the execution of code.
Type checker
Will not allow unsafe casts or uninitialized variables. MSIL can be verified to guarantee type safety.
Exception manager
Provides structured exception handling, which is integrated with Windows Structured Exception Handling (SEH). Error reporting has been improved.
Thread support
and
interfaces
that
enable
multithreaded
COM marshaler
.NET Framework Class Library Integrates code with CLR that supports the .NET Framework Class support Library.
NOTE: - Cross-Language compatibility: .NET components can interact with each Other no matter what language they were originally written in. So, an application written in vb.net might reference a DLL file written in C#, which in turn might access a resource written in managed C++ or any other .NET language. 4) .Net Framework Class Library: - Provides a collection of useful and reusable types that are designed to integrate with the common language runtime. The .NET Framework Class Library is a collection of reusable classes, or types, that tightly integrate with the common language runtime. It comprises several namespaces. As an example, let us look at the System namespace.
The System.IO namespace is found below the System namespace and contains input/output (I/O) services. The System.Collections namespace provides sorted lists, hash tables, and other ways to group data. The System.Net namespace provides TCP/IP and sockets support. The design goals of the .NET Framework Class Library were to: Enable factoring and extensibility Implement Web standards and practices as the foundation Unify application models Increase developer productivity by supplying a single hierarchical and intuitive programming model Enable cross-language inheritance and debugging Make it easy to add or modify .NET Framework features Allow creation of secure applications The .NET Framework Class Library provides a vast amount of functionality, including the following: Managing collections of objects Database access
5) Execution Steps: 1) .Net application is compiled, it is converted from the language it was written in (vb.net, c# etc.,) to MSIL or IL (Microsoft Intermediate Language) 2) MSIL is a low level language, which understood CLR. 3) As all .NET executables and DLLs exist as intermediate language, they can freely interoperate NOTE: - .NET applications are converted to IL prior to deployment and execution; all primitive data types are represented as .NET types. 6) Structure of a .NET application: 1) The primary unit of a .NET application is the assembly. Assembly: 1) Assembly is a self-describing collection of code, resources and metadata. 2) The assemble manifest contains information about what is contained within the assembly. Assembly Manifest: - Provides 1) Identify information, such as the name and version number of the assembly. 2) A list of all types exposed by the assembly. (Only public types) 3) A list of other assemblies required by the assembly. 4) A list of code access security instructions for the assembly. This includes a list of permissions required by the assembly and permissions to be denied the assembly. NOTE: Each assembly has one and only one assembly manifest, and it contains all the description information for the assembly. Modules: - The assembly manifest can be contained in its own separate file, or it can be contained within one of the assemblys modules.