.NET Development Foundation/Introduction

Introduction

Module objectives
This study guide does not aim at replacing the other resources that exist to get prepared to pass the 70-536 exam:


 * we provide links to the MSDN library, we do not try to replace it. People who pass the exam often note that the training kit does not cover every aspect of the exam and that consulting the MSDN documentation is a big plus.


 * we provide links to Wikipedia and other Wikimedia projects where applicable. This is not a series of theoretical or encyclopedia articles but a guide on how the concepts are implemented in the .NET framework and how to use them.


 * we do not provide testing software


 * we do not pretend that this module replaces the recommended training kit or any other recommended material from Microsoft.

What we do provide though, even at this document's grossly incomplete stage, is:


 * an exhaustive list of the objectives of the exam as stated by Microsoft


 * links from all exam objectives to the corresponding MSDN library article.


 * "textbook like" explanations for a growing number of topics with links to related external sources.


 * and most of all, a place to put your important notes and code examples for your revision before the exam and as a reference for your professional work afterward. No training kit or library provides that in a shared and controlled environment.

The most difficult aspect of a book like this one is to keep a balance between having enough content to cover and explain every objective of the exam and not too much content because reading and studying time should be kept to a manageable level. Furthermore, there is no reason to cover content here that is not directly related to exam objectives.

Finally, as part of the Wikimedia family (Wikipedia and all) the Wikibooks project has very high ethics on copyrights and general quality. Do not hesitate to correct if you find anything "wrong" in any way.

Module structure
This module is structured around the objectives set by Microsoft for the 70-536 Exam. Chapters 3 to 9 represents each of the 7 major objective categories of the exam.

The idea behind sticking to the exam "official" objectives is that we assume that somehow the certification provider (Microsoft) has some understanding of the product (.NET) and can state what is important to know about it.

For each chapter:


 * a first section covers the major concepts (topics) treated in that chapter. This "topics" section allows us to somewhat separate the "what" from the "how-to". Please note that the exam is heavily oriented toward the utilization of the libraries and tools and that an understanding of the concepts is highly insufficient as a preparation for the exam.


 * a second section then details each of the second, third and fourth level exam objectives for that objective category (how-to's, detailed usage and references to MSDN library).

Eventually, we would like to have:


 * a "revision questions" section for each chapter where we could discuss the kind of questions that could be asked at the exam.


 * an "advanced" section where we could put the more advanced material and keep the text flow of the basic sections at a level that corresponds to the knowledge required for the exam.

As of December 7, 2007:


 * 24 subjects are detailed on separate pages (the subject title is the link). Most of those will eventually be integrated into the main page for a better flow of the text.


 * all of the subjects are directly linked to the Microsoft Software Developers Network (MSDN) library, about 480 directly from the main page (the "MSDN" following the title is the link) and the others from their respective subpage.


 * we just started to link the "topics" sections to Wikipedia articles to give you a feel of how the concepts are defined and treated outside of Microsoft's world.

Some sections are relatively advanced and others are awaiting your contributions. The more advanced sections are not all at the beginning of the module.

The .NET Framework
In the certification paths where exam 70-536 "Microsoft .NET Framework 2.0 Application Development Foundation" is present, it represents the first step of the certification process. It is thus natural to start this first study guide with a short discussion of the framework as a whole.

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

Wikipedia's definition is: "The Microsoft .NET Framework is a software component included with the Microsoft Windows operating system. It provides a large body of pre-coded solutions to common software development requirements, and manages the execution of programs written specifically for the framework. The .NET Framework is intended to be used by most new applications created for the Windows platform"

The problem with Microsoft's definition is that it refers to a "managed code programming model" which is still Microsoft terminology. The best definition for it: "Managed code is code that has its execution managed by the .NET Framework Common Language Runtime" (see Brad Adams blog on MSDN).

Wikipedia's definition points to the two more important aspects from a developer point of view:
 * The presence of a huge set of class libraries that allows for all of the common programming tasks. Beside the sheer size of the those class libraries, they are also evolving at a rapid pace.
 * The fact that the execution environment is specific to the framework. The term "virtual machine" is often used to qualify such an environment.

Those two main characteristics parallel those of the Java environment, which is the main competitor to the .NET framework. This module tries to help you learn the .NET framework. It will not address the .NET vs Java comparisons and discussions.

Framework structure


The image on the right is taken from the Wikipedia article on the .NET framework (see above).

It describes the process followed by a program written in a .NET compatible language from source code to execution. The important difference with that and more conventional programming languages (ex. C++) is the fact that the program is compiled twice. The first compilation is done from the original language to a "common intermediate language" (CIL). This is what actually goes "in" an assembly.

The second compilation is done from the CIL to machine code. This compilation is usually performed automatically by the "just-in-time" (JIT) compiler. It is also possible to use the Native Image Generator (ngen) utility to create the machine code in advance of runtime.

This architecture has many direct implications for the subjects of this book. Among them:


 * The "source code" of the second compilation (the CIL code) is always available to the virtual machine at runtime. This means that this code can easily be analyzed at runtime, contrary to conventional compiled environment. This characteristic is the base for the reflection functionality of the platform. Not only can we analyze the "intermediate source code" but we can actually create (emit) some of it at runtime and then do the "just-in-time" compilation and execution.


 * The execution is done in the context of the CLR (this is the "managed" code concept). Put another way, we can say that the runtime always "knows" what it sends for execution, contrary to a conventional environment where the code is executed directly by the operating system. This implies that you can tell the runtime to execute, or not, this or that type of code. This is the basis for code access security.


 * Most of the features of the .NET languages (C#, VB, etc.) are directly related to features of the intermediate language. Put another way, most of the time, the first compilation is pretty straightforward. Some of the constructs though do not have direct equivalents in the CIL (ex. properties in C# are mapped to class methods in the CIL).

We could continue like that for a long time. The point we want to make here is that a developer has much to gain from a detailed understanding of the platform, even if it is not directly mentioned as an objective of the exam.

If you want to read on the framework in Microsoft documentation you can see MSDN.

The last thing we will note here is that the common language runtime (CLR) can execute in different contexts:
 * ASP.NET for web applications, where it is directly linked to the Internet Information Server (IIS).
 * Internet Explorer for client side web controls
 * In a standalone host for console, service and windows applications.

By default, examples in this book will use standalone executables. This is just because they are more easy to deploy for very simple programs. This does not imply that Windows applications are preferable to web applications.

Where this book fits
The image on the right, also taken from Wikipedia, gives a simplified but clear view of the functional components of the framework.

This book (and the related exam) deals with the "Base Class Library" component and the basic relations of a program with the "Common Language Runtime" component.

The book does not cover ASP.NET, ADO.NET, WF or any other more specialized components.

We can say that we extensively cover the basics but that we shallowly cover the framework itself.

The relations with the common language runtime include such things as:
 * Deployment
 * Security
 * Configuration
 * Reflection
 * Services
 * Relationship with WMI
 * Interoperability
 * etc.

The base class library includes
 * types
 * collections
 * generics
 * text manipulation
 * basic drawing
 * basic globalization
 * serialization
 * basic input/output
 * multi-threading
 * etc.

All in all they are kind of "dry" topics. This idea of starting with an extensive coverage of the basics is certainly not the most interesting learning pattern for a beginner. This is why we advise real beginners to start with more adequate material.

One last note about the framework "stack" is that new versions tend to add new components instead of "redoing" existing ones. This means that most of the "2.0" basics are still valid in "3.5". Some "basic" functionalities are nevertheless augmented or changed in new versions. We will try to keep track of those as side notes where possible.

Programming paradigms
Keeping things very (too much?) simple we can say that a programming paradigm is a "style" of programming, a specific way to model problems and "translate" their solution in code.

From a developer point of view the .NET framework (and its class libraries) is a general-purpose object-oriented platform that is constantly extended to support other programming paradigms (generic programming with Generics, Aspect programming with attributes, Reactive programming with WF, Functional programming with Lambda expressions in C# 3.0, etc.). That "extension process" mirrors that of Java. The .NET and Java platforms are the only two that currently support such extensive multi-paradigms extension process.

Discussing the extent and "theoretical soundness" of each of those paradigm implementations is obviously out of scope for this book.

Our point here is that navigating through all those programming styles in the same platform can get kind of confusing. Maintaining code is also getting more and more difficult because two original programmers could have solved the same problem using widely different "styles" or constructs.

We will thus try to connect, where possible, the different .NET concepts with their respective "style" to give the reader some context.

Assemblies
According to MSDN assemblies are: "the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions".

The .NET Framework is now Microsoft's preferred way of developing applications on the Windows platform. In that respect it succeeds the Component Object Model (COM). This is important to mention because despite some deployment and management problems (remember DLL Hell?) COM played an important role in the development of component-based computing (reusing whole executable components, not only program code). Major efforts have been invested to transfer the component-based concepts of COM to the .NET framework and a significant part of this book deals with those (security, installation, versioning, etc.).

The assembly is the successor of the COM component.

Previous / Next