Vous êtes sur la page 1sur 4

Chapter 1 .

NET Framework and the CLR Fundamentals

The .NET Framework is the infrastructure for building applications using .NET. The .NET Framework provides a consistent object-oriented programming model that you can use to build all types of applications such as Windows-based applications,Web Application

Understanding the .NET Framework Architecture


.Net framework consists of two main components a).Net framework class library b)Common language Runtime Framework Class Library/Base Class Library represents the rich set of libraries and API that has been created to support virtually all aspects of programming.

Common Language Runtime Architecture


The common language runtime consists of various components that provide the run-time environment and run-time services for your applications. These components load the IL code of an application into the runtime, compile the IL code into native code, execute the code, and enforce security. In addition, these components implement type safety and provide automatic memory management and thread support.

Compiling .NET Code


Compilers that are compliant with the CLR generate code that is targeted for the runtime, as opposed to a specific CPU. This code, known variously as Common Intermediate Language (CIL), Intermediate Language (IL), or Microsoft Intermediate Language (MSIL), is an assembler-type language that is packaged in an EXE or DLL file. Note that these are not standard executable files and require that the runtime's Just-in-Time (JIT) compiler convert the IL in them to a machine-specific code when an application actually runs. Because the Common Language Runtime is responsible for managing this IL, the code is known as managed code. This intermediate code is one of the keys to meeting the .NET Framework's formal objective of language compatibility. As Figure 1-3 illustrates, the Common Language Runtime neither knowsnor needs to knowwhich language an application is created in. Its interaction is with the language-independent IL. Because applications communicate through their IL, output from one compiler can be integrated with code produced by a different compiler

ensures that all types support a basic set of inherited methods and properties.

Framework Class Library


The Framework Class Library (FCL) is a collection of classes and other types (enumerations, structures, and interfaces) that are available to managed code written in any language that targets the CLR. This is significant, because it means that libraries are no longer tied to specific compilers. As a developer, you can familiarize yourself with the types in a library and be assured that you can use this knowledge with whatever .NET language you choose. The resources within the FCL are organized into logical groupings called namespaces. For the most part, these groupings are by broad functionality. For example, types used for graphical operations are grouped into the System.Drawing and System.Drawing.Drawing2D namespaces; types required for file I/O are members of the System.IO namespace. Namespaces represent a logical concept, not a physical one.

What is managed code? What is unmanaged code


Managed Code is what Visual Basic .NET and C# compilers create. It compiles to Intermediate Language (IL), not to machine code that could run directly on your computer. The IL is kept in a file called an assembly, along with metadata that describes the classes, methods, and attributes (such as security requirements) of the code you've created. This assembly is the one-stop-shopping unit of deployment in the .NET world. You copy it to another server to deploy the assembly thereand often that copying is the only step required in the deployment. Managed code runs in the Common Language Runtime. The runtime offers a wide variety of services to your running code. In the usual course of events, it first loads and verifies the assembly to make sure the IL is okay. Then, just in time, as methods are called, the runtime arranges for them to be compiled to machine code suitable for the machine the assembly is running on, and caches this machine code to be used the next time the method is called. (This is called Just In Time, or JIT compiling, or often just Jitting.) As the assembly runs, the runtime continues to provide services such as security, memory management, threading, and the like. The application is managed by the runtime. Unmanaged code is what you use to make. Visual Basic 6, Visual C++ 6, even the C compiler produces unmanaged code. It compiled directly to machine code that ran on the machine where you compiled itand on other machines as long as they had the same chip, or nearly the same. It didn't get services such as security or memory management from an invisible runtime; it got them from the operating system. And importantly, it got them from the operating system explicitly, by asking for them, usually by calling an API provided in the Windows SDK. More recent unmanaged applications got operating system services through COM calls.

Unlike the other Microsoft languages in Visual Studio, Visual C++ can create unmanaged applications. When you create a project and select an application type whose name starts with MFC, ATL, or Win32, you're creating an unmanaged application.

Vous aimerez peut-être aussi