Saturday, May 1, 2010

Introduction to .NET

The .NET Solution
.NET Framework is a new model for developing applications in windows plaforms. Its a set of tools and libraries that enables developers to build applications much faster and easier.The main advantantages are
  • Interoperability with existing code: Existing COM binaries and C based libraries can interop with newer .NET binaries.
  • Complete and total language integration: .NET supports cross-language inheritance, crosslanguage exception handling, and cross-language debugging of code.
  • A common runtime engine for all .net languages
  •  A comprehensive base class library
  • Simplified deployment model: there is no need to register a binary unit into the system registry. .NET allows multiple versions of the same *.dll to exist in harmony on a single machine.
Building Blocks of the .NET Platform
  1. CLR :  The primary role of the Common Language Runtime is to locate, load, and manage .NET types on your behalf. The CLR also takes care of a number of low-level details such as
                      Memory management
                      Thread management
                      Exception handling
                      Garbage collection
                      Security
  2. CTS :Common Type System specification fully describes all possible data types and programming constructs supported by the runtime, specifies how these entities can interact with each other, and details how they are represented in the .NET metadata format
  3. CLS : Common Language Specification  is a related specification that defines a subset of common types and programming constructs that all .NET programming languages can agree on.
  4. In addition to the CLR and CTS/CLS specifications, the .NET platform provides a base class library that is available to all .NET programming languages. .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.
An Overview of .NET Assemblies
.NET assembly is just the .EXE or .DLL files that are the end result of your program. Perhaps most important, .NET binaries do not contain platformspecific instructions, but rather platform-agnostic intermediate language (IL) and type metadata.

Common Intermediate Language

CIL is a language that sits above any particular platform-specific instruction set. each .NET-aware compiler produces nearly identical CIL instructions. Therefore, all languages are able to interact within a well-defined binary arena. Due to the fact that assemblies contain CIL instructions, rather than platform-specific instructions, CIL code must be compiled on the fly before use. The entity that compiles CIL code into meaningful CPU instructions is termed a just-in-time (JIT) compiler, which sometimes goes by the friendly name of Jitter. The .NET runtime environment leverages a JIT compiler for each CPU targeting the runtime, each optimized for the underlying platform.
.NET Type Metadata
In addition to CIL instructions, a .NET assembly contains full, complete, and accurate metadata, which describes each and every type (class, structure, enumeration, and so forth) defined in the binary, as well as the members of each type (properties, methods, events, and so on).
Assembly Manifest
Last but not least, remember that a .NET assembly also contains metadata that describes the assembly itself (technically termed a manifest). Among other details, the manifest documents all external assemblies required by the current assembly to function correctly, the assembly’s version number, copyright information, and so forth.

 
Developers using the CLR write code in a language such as C# or VB.NET. At compile time, a .NET compiler converts such code into CIL code. At runtime, the CLR's just-in-time compiler converts the CIL code into code native to the operating system. Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime by using the Native Image Generator (NGEN). This speeds up all later runs of the software as the CIL-to-native compilation is no longer necessary.



Single-File and Multifile Assemblies

If an assembly is composed of a single *.dll or *.exe module, we have a single-file assembly. Single-file assemblies contain all the necessary CIL, metadata, and associated manifest

Multifile assemblies, on the other hand, are composed of numerous .NET binaries, each of which is termed a module. When building a multifile assembly, one of these modules (termed the primary module) must contain the assembly manifest (and possibly CIL instructions and metadata for various types). The other related modules contain a module-level manifest, CIL, and type metadata. The primary module contains the set of required secondary modules within the assembly manifest.
Satellite assemblies
A .NET Framework assembly containing resources specific to a given language. Using satellite assemblies, we can place the resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user elects to view the application in that language.



No comments:

Post a Comment