Introducing The
Introducing The
qxp
5/3/10
5:40 PM
Page 1
CHAPTER
IN THIS CHAPTER
. What Is the .NET Framework?
. The Common Language
Runtime
. The Base Class Library
. .NET Languages
. .NET Framework Tools
01_0672331004_ch01.qxp
5/3/10
CHAPTER 1
5:40 PM
Page 2
.NET Framework so that you will know how applications built with Visual Basic 2010 can
run and how they can be built.
01_0672331004_ch01.qxp
5/3/10
5:40 PM
Page 3
01_0672331004_ch01.qxp
5/3/10
CHAPTER 1
5:40 PM
Page 4
Although the various frameworks exposed by the BCL are discussed later in the book, in this
chapter, now you get an overview of the library and can understand how it works and how
you can use it. But before examining the BCL, consider the Common Language Runtime.
Writing managed code and the existence of the Common Language Runtime also affect
how applications are produced by compilers.
01_0672331004_ch01.qxp
5/3/10
5:40 PM
Page 5
.NET Assemblies
In classic Win32 development environments, such as Visual Basic 6 or Visual C++, your
source code is parsed by compilers that produce binary executable files that can be immediately interpreted and run by the operating system. This affects both standalone applications and dynamic/type libraries. Actually Win32 applications, built with Visual Basic 6
and C++, used a runtime, but if you had applications developed with different programming languages, you also had to install the appropriate runtimes. In.NET development
things are quite different. Whatever .NET language you create applications with, compilers
generate an assembly, which is a file containing .NET executable code and is composed
essentially by two kinds of elements: MSIL code and metadata. MSIL stands for Microsoft
Intermediate Language and is a high-level assembly programming language that is also
object-oriented, providing a set of instructions that are CPU-independent (rather than
building executables that implement CPU-dependent sets of instructions). MSIL is a
common language in the sense that the same programming tasks written with different
.NET languages produce the same IL code. Metadata is instead a set of information related
to the types implemented in the code. Such information can contain signatures, functions
and procedures, members in types, and members in externally referenced types. Basically
metadatas purpose is describing the code to the .NET Framework. Obviously, although an
assembly can have .exe extension, due to the described structure, it cannot be directly
executed by the operating system. In fact, when you run a .NET application the operating
system can recognize it as a .NET assembly (because between .NET and Windows there is a
strict cooperation) and invoke the Just-In-Time compiler.
01_0672331004_ch01.qxp
5/3/10
CHAPTER 1
5:40 PM
Page 6
code and Windows APIs and, often, without recurring to external components. A type is
something that states what an object must represent. For example, String and Integer are
types, and you might have a variable of type String (that is, a text message) or a variable
of type Integer (a number). Saying Type is not the same as saying Class. In fact, types can
be of two kinds: reference types and value types. This topic is the specific subject of Chapter
4, Data Types and Expressionsa class is just a reference type. Types in the BCL are
organized within namespaces, which act like a kind of types containers, and their name is
strictly related to the technology they refer to. For example, the System.Windows.Forms
namespace implements types for working with Windows Forms applications, whereas
System.Web implements types for working with Web applications, and so on. You will get
a more detailed introduction to namespaces in Chapter 3, The Anatomy of a Visual Basic
Project, and Chapter 9, Organizing Types Within Namespaces. Basically each namespace name beginning with System is part of the BCL. There are also some namespaces
whose name begins with Microsoft that are still part of the BCL. These namespaces are
typically used by the Visual Studio development environment and by the Visual Basic
compiler, although you can also use them in your code in some particular scenarios (such
as code generation).
The BCL is composed of several assemblies. One of the most important is MsCorlib.dll
(Microsoft Core Library) that is part of the .NET Framework and that will always be
required in your projects. Other assemblies can often be related to specific technologies;
for example, the System.ServiceModel.dll assembly integrates the BCL with the Windows
Communication Foundation main infrastructure. Also, some namespaces dont provide
the infrastructure for other technologies and are used only in particular scenarios; therefore, they are defined in assemblies external from MsCorlib (Microsoft Core Library). All
these assemblies and namespaces will be described in the appropriate chapters.
.NET Languages
Microsoft offers several programming languages for the .NET Framework 4.0. With
Visual Studio 2010, you can develop applications with the following integrated
programming languages:
. Visual Basic 2010
. Visual C# 4.0
. Visual F# 2010
. Visual C++ 2010
Visual J# is no longer part of the .NET Framework family. You can also integrate native
languages with Microsoft implementations of Python and Ruby dynamic languages,
respectively known as IronPython and IronRuby.
01_0672331004_ch01.qxp
5/3/10
5:40 PM
Page 7
There are also several third-party implementations of famous programming languages for
.NET, such as Fortran, Forth, or Pascal, but discussing them is neither a purpose of this
chapter nor of this book. Its instead important to know that all these languages can take
advantage of the .NET Framework base class library and infrastructure the same as VB and
C#. This is possible because of the Common Language Runtime that offers a common
infrastructure for all .NET programming languages.
IronPython and IronRuby are currently under development by Microsoft and are available
as open source projects from the CodePlex community. You can download IronPython
from http://ironpython.codeplex.com. You can find IronRuby at http://ironruby.codeplex.com.
01_0672331004_ch01.qxp
5/3/10
CHAPTER 1
5:40 PM
Page 8
deployment and code analysis, or for generating proxy classes for Windows
Communication Foundation projects. Also in this case you will not typically need to
invoke these tools manually, because Visual Studio will do the work for you. You can find
information on the Windows SDKs tools in the appropriate chapters.
01_0672331004_ch01.qxp
5/3/10
5:40 PM
Page 9
Summary
Summary
1
01_0672331004_ch01.qxp
5/3/10
5:40 PM
Page 10