Runtime Technical Questions
Terminology
What is the common language runtime (CLR)?
The common language runtime is the execution engine for .NET
Framework applications.
It provides a number of services, including the following:
Code management (loading and execution)
Application memory isolation
Verification of type safety
Conversion of IL to native code
Access to metadata (enhanced type information)
Managing memory for managed objects
Enforcement of code access security
Exception handling, including cross-language exceptions
Interoperation between managed code, COM objects, and
pre-existing DLLs (unmanaged code and data)
Automation of object layout
Support for developer services (profiling, debugging, and so on)
What is the common type system (CTS)?
The common type system is a rich type system, built into the
common language runtime, that supports the types and operations
found in most programming languages. The common type system
supports the complete implementation of a wide range of
programming languages.
What is the Common Language Specification (CLS)?
The Common Language Specification is a set of constructs and
constraints that serves as a guide for library writers and
compiler writers. It allows libraries to be fully usable from
any language supporting the CLS, and for those languages to
integrate with each other. The Common Language Specification is
a subset of the common type system. The Common Language
Specification is also important to application developers who
are writing code that will be used by other developers. When
developers design publicly accessible APIs following the rules
of the CLS, those APIs are easily used from all other
programming languages that target the common language runtime.
What is the Microsoft Intermediate Language (MSIL)?
MSIL is the CPU-independent instruction set into which .NET
Framework programs are compiled. It contains instructions for
loading, storing, initializing, and calling methods on objects.
Combined with metadata and the common type system, MSIL allows
for true cross-language integration. Prior to execution,
MSIL is converted to machine code. It is not interpreted.
What is managed code and managed data?
Managed code is code that is written to target the services
of the common language runtime (see What is the Common Language
Runtime?). In order to target these services, the code must
provide a minimum level of information (metadata) to the
runtime. All C#, Visual Basic .NET, and JScript .NET code is
managed by default. Visual Studio .NET C++ code is not managed
by default, but the compiler can produce managed code by
specifying a command-line switch (/CLR).
Closely related to managed code is managed data—data that is
allocated and de-allocated by the common language runtime's
garbage collector. C#, Visual Basic, and JScript .NET data is
managed by default. C# data can, however, be marked as unmanaged
through the use of special keywords. Visual Studio .NET C++ data
is unmanaged by default (even when using the /CLR switch), but
when using Managed Extensions for C++, a class can be marked as
managed by using the __gc keyword. As the name suggests, this
means that the memory for instances of the class is managed by
the garbage collector. In addition, the class becomes a full
participating member of the .NET Framework community, with the
benefits and restrictions that brings. An example of a benefit
is proper interoperability with classes written in other
languages (for example, a managed C++ class can inherit from a
Visual Basic class). An example of a restriction is that a
managed class can only inherit from one base class.
|