Chapter 2

The Common Language Runtime

What's in this chapter?

Framework Profiles and Platforms

Elements of a .NET Application

Understanding the Common Language Runtime

Memory Management

Namespaces

The My Keyword

Wrox.com Code Downloads for this Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/remtitle.cgi?isbn=9781118314456 on the Download Code tab. The code is in the chapter 2 download and individually named according to the code file names throughout the chapter.

You started with a quick jump straight into getting your hands on Visual Studio. Most developers want to feel something, but before you start diving into syntax this chapter is going to take a look at the bigger picture of how .NET runs in relation to the operating system (OS). While at really low levels for graphics some implementations of the common language runtime (CLR) and the OS may be indistinguishable, at its core the CLR provides the environment in which your application runs.

The architects of .NET realized that all procedural languages require certain base functionality. For example, many languages ship with their own runtime that provides features such as memory management, but what if, instead of each language shipping with its own runtime implementation, all languages used a common runtime? This would provide languages with a standard environment and access to all of the same features. This is exactly what the CLR provides.

The CLR manages the execution of code on the .NET platform. Its common features provide support for many advanced features, including operator overloading, implementation inheritance, threading, and the ability to marshal objects. Building such features is not trivial. The CLR enabled Microsoft to concentrate on building this plumbing one time and then reuse it across different programming languages. As a result the runtime environment used by Visual Basic is the equal of every other .NET language, with the CLR eliminating many of the shortcomings of the previous versions of Visual Basic.

Visual Basic developers can view the CLR as a better Visual Basic runtime. However, this runtime, unlike the old standalone Visual Basic runtime, is common across all of .NET regardless of the underlying operating system. Thus, the functionality exposed by the CLR is available to all .NET languages; more important, all of the features available to other .NET languages via the CLR are available to Visual Basic developers. Additionally, as long as you develop using managed code — code that runs in the CLR — you'll find that it doesn't matter whether your application is installed on a Windows XP client, a Vista client, or a Windows 7 client; your application will run. The CLR provides an abstraction layer separate from the details of the operating system.

This chapter gets down into the belly of the application runtime environment — not to examine how .NET enables this abstraction from the operating system, but instead to look at some specific features related to how you build applications that run against the CLR. This includes an introduction to several basic elements of working with applications that run in the CLR, including the following:

  • Framework Profiles
  • Elements of a .NET application
  • Integration across .NET languages
  • Memory management and the garbage collector (GC)
  • Namespaces
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset