The .Net Framework

A New Approach to Code Development via Common Language Runtime

© Jacqueline Masloff

The .NET Framework introduces the Common Language Runtime which enables developers to write in their language of choice and produce safer code.

Microsoft's .Net Framework is a managed code programming model for building applications on Windows clients, servers, and mobile embedded devices. Developers use .NET to build applications of many types: Web applications, server applications, smart client applications, console applications, database applications, and more.

Managed Code

Managed code is code whose execution is managed handled the the .NET Framework Common Language Runtime (CLR). The latter refers to a convention of cooperation between native executing code and the runtime. This convention specifies that at any point, the runtime may stop running the CPU and retrieve information specific to the current CPU instruction address. The necessary information is encoded in an Intermediate Language (IL) and associated meta-data that describes all of the entry points and the constructs exposed in the Intermediate Language, such as properties and methods and their characteristics.

Before the code is run, the IL is compiled into native executable code. As this compilation happens by the managed execution environment, which is a runtime-aware compiler that knows how to target the managed execution environment, the managed execution environment can make guarantees about what the code is going to do. It can insert traps and appropriate application garbage collection hooks, exception handling, type safety, array bounds and index checking, and so forth.

For example, such a compiler makes sure to lay out stack frames and everything just right so that the garbage collector can run in the background on a separate thread, constantly examining the active call stack, finding all the roots, and chasing down all the live objects. In addition because the IL has a notion of type safety the execution engine will maintain the guarantee of type safety eliminating a whole class of programming mistakes that often lead to security holes.

The Common Language Runtime describes how the information is to be encoded, and programming languages that target the runtime produce the correct encoding. All a developer has to know is that any of the languages that target the runtime produce managed code emitted as files that contain IL and meta-data. And there are many such languages to choose from, since there are nearly 20 different languages provided by third parties – everything from COBOL to Camel – in addition to C#, J#, VB .Net, Jscript .Net, and C++ from Microsoft.

Compared to managed code, unmanaged executable files are basically a binary image loaded into memory. The program counter loads with the code and the operating system is unaware of what the program is doing. There are protections in place around memory management and port I/O and so forth, but because the operating system does not actually know what the application is doing, it cannot make any guarantees about what happens when the application runs.

.NET Libraries

To support the ability o write code in so many different languages, the .NET Framework includes a broad set of supporting class libraries, including:

The pre-coded solutions that form the framework's Base Class Library cover a large range of programming needs in areas including: user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. The class library is used by programmers who combine it with their own code to produce applications.

Benefits

The benefits of the .NET Framework is that developers can write code in their programming language of choice and the Framework and its components will manage the execution of that code. Microsoft's most common languages for creating managed code are C#, a successor to C+ and C++, and Visual Basic .Net. The .NET Framework is included with Windows Server 2003 and the upcoming Winodws Server 2008 as well as Windows Vista and can even be installed on various older versions of Windows.


The copyright of the article The .Net Framework in Windows Programming is owned by Jacqueline Masloff. Permission to republish The .Net Framework must be granted by the author in writing.




Post this Article to facebook Add this Article to del.icio.us! Digg this Article furl this Article Add this Article to Reddit Add this Article to Technorati Add this Article to Newsvine Add this Article to Windows Live Add this Article to Yahoo Add this Article to StumbleUpon Add this Article to BlinkLists Add this Article to Spurl Add this Article to Google Add this Article to Ask Add this Article to Squidoo