Vous êtes sur la page 1sur 6

.NET Important Points : 1) .NET Framework is a managed, typesafe environment for application development.

The .NET Framework


The .NET Framework is a language-neutral component library and execution environment. The .NET Framework enables you to build integrated, service-oriented applications that meet the needs of today's Internet businesses, applications that gather information from, and interact with, a wide variety of sources, regardless of the platforms or languages in use. Let's take a look at the architecture of the .NET Framework.

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.

Common Language Runtime


Runtimes are not new to programming: Many other programming languages have used runtimes. Microsoft Visual Basic has always had a runtime (VBRUN through version 4.0 and then MSVBVM through version 6.0). Microsoft Visual C++ has one (MSVCRT), as do Microsoft Visual FoxPro and Microsoft JScript and non-Microsoft languages, such as SmallTalk, Perl, and Java. The critical role of the .NET Framework, and what really sets it apart from other runtimes, is that it provides a unified environment across all programming languages. The environment is also referred to as a managed environment. Despite its name, the CLR actually has a role in a component's development as well as at runtime. While the component is running, the runtime is responsible for managing memory allocation, starting up and killing threads and processes, enforcing security policy, and satisfying any dependencies that the component may have on other components. During development, the runtime's role changes slightly. Because it automates a lot of functionality (such as memory management), the runtime makes the developer's experience very simple. In particular, the CLR ensures code correctness and type safety. The CLR also dramatically reduces the amount of code a developer must write to turn business logic into a reusable component. Following are some examples: System registration is not needed because applications are completely self-describing. GUIDs are not needed. Classes are organized using a hierarchical naming scheme with human readable names. IDL files are no longer required because the system and the languages use the same representations. HRESULTs are no longer used because the CLR uses structured exception handling. IUnknown is no longer required because its functionality is provided by the root System.Object. Adding and releasing object references is no longer necessary because the CLR knows which objects are being used and can clean up unused objects whenever necessary. COM's CoCreateInstance simply becomes the new operator.

The following diagram shows the components of CLR.

Component

Description

Class loader

Manages metadata and the loading and layout of classes.

Microsoft Intermediate Language Converts MSIL to native (MSIL) to native compilers Generation (NGEN)).

code (Just-in-Time (JIT) and

Native

Code manager

Manages code execution.

Garbage collector (GC)

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

Provides classes programming.

and

interfaces

that

enable

multithreaded

COM marshaler

Provides marshaling to and from COM.

.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.

. NET Framework Class Library

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

Drawing to the screen Providing security and encryption

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.

Vous aimerez peut-être aussi