Appendix E: Introduction to Microsoft .NET


Introduction to the .NET Framework

The .NET framework is the latest platform from Microsoft. It provides a multi-language environment that enables you to develop, deploy, and run Web-based applications and services. It provides a new level of interoperability that enables you to reuse components created in other languages. It also provides new and advanced features, such as garbage collection and enhanced security.

The .NET framework is composed of classes and services that form a layer between applications and the operating system. It consists of the following two main components:

  • Common Language Runtime (CLR)

  • .NET framework class library

Common Language Runtime

The CLR is the runtime environment of the .NET framework. It provides a common set of services, such as exception handling, security, and debugging, to languages that are CLR-compatible. All programming languages in Visual Studio .NET, such as Visual Basic .NET and Visual C# .NET, support the CLR.

During the execution of a program, the CLR controls the interaction of code with the operating system. Code that is executed by the CLR is known as managed code. In contrast, the code that is not executed by the CLR is known as unmanaged code. Managed code "cooperates" with the CLR by providing metadata to the CLR. The CLR, in turn, provides services to the code, such as garbage collection and memory management.

During compilation, the CLR converts code into Microsoft Intermediate Language (MSIL). MSIL is a set of instructions that are CPU-independent. It includes instructions for loading, storing, initializing, and calling methods. It also contains instructions about arithmetic and logical operations, as well as exception handling. In addition to MSIL, metadata is created during compilation and is stored with the compiled code. Metadata contains information about the members, types, and references in the code. The CLR uses metadata to locate and load classes, generate native code, provide security, and execute code.

Thus, after code is compiled, the compiled file contains MSIL and metadata. This file is known as a Portable Executable (PE) file. However, before code is executed, the MSIL in the PE file is converted to native code. The CLR's Just-In-Time (JIT) compiler uses the metadata and converts MSIL into native code. Unlike MSIL, native code is CPU-dependent. Therefore, the CLR provides various JIT compilers, each of which works on a different architecture. This means that, depending on the JIT compiler, the same MSIL can be executed on different architectures.

While managing code, the CLR also performs various tasks, such as managing memory, security, and threads, and verifying and compiling code. For example, when an application is running, the CLR allocates memory, manages threads and processes, and enforces the security policy.

The CLR defines Common Type System (CTS), which is a standard type system used by all languages that support the CLR. CTS lists the types that are supported by the CLR:

  • Classes

  • Interfaces

  • Value types

  • Delegates

The use of CTS ensures that datatypes, such as Integer, String, and Long, have the same implementation across CLR-compatible languages. You can pass a variable from a class created in a CLR-compatible language to another class regardless of the programming language used, because datatypes have the same implementation across languages.

.NET Framework Class Library

The .NET framework class library includes multiple reusable, object-oriented, and extensible classes. It's integrated with the CLR and is common to all programming languages in Visual Studio .NET.

The .NET framework class library provides a common set of classes across programming languages. While developing applications, you can use these classes to create new classes. You can use the classes in the .NET framework class library to develop applications and implement cross-language inheritance.

The classes in the .NET framework class library are organized hierarchically. The System namespace is at the top of the hierarchy and contains all other classes. On a broad level, the System namespace contains classes that enable you to perform the following tasks:

  • Convert datatypes.

  • Manipulate parameters.

  • Invoke local and remote programs.

  • Manage the application environment.

You'll learn more about using namespaces later in this appendix. Table E.1 describes some of the namespaces in the .NET framework class library.

Table E.1: Namespaces in the .NET Framework Class Library

Namespace

Task Performed

Microsoft.CSharp

Compile and generate code in Visual C# .NET.

Microsoft.JScript

Compile and generate code in JScript.

Microsoft.VisualBasic

Compile and generate code in Visual Basic .NET.

Microsoft.Win32

Manipulate the system registry and manage operating system events.

System

Manage exceptions and define data types, events and event handlers, interfaces, and attributes.

The System namespace contains various other namespaces, such as System.Xml, System.Web, System.Text, and System.Security.




Macromedia ColdFusion MX. Professional Projects
ColdFusion MX Professional Projects
ISBN: 1592000126
EAN: 2147483647
Year: 2002
Pages: 200

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net