I l@ve RuBoard Previous Section Next Section

About This Book

I try very hard to make a book readable and accessible to a wide array of readers, but invariably, my terse writing style tends to make a "Don Box book" a challenge to get through. Experience has shown me that I am horrible at writing tutorials or primers. What I can do reasonably well is convey how I see the world in book form. To that end, it is not uncommon to need to read a Don Box book more than once to get the intended benefits.

As the previous paragraph implied, this book is by no means a tutorial. If you try to learn .NET Framework programming from a standing start using this book, the results may not be pretty. For readers looking for a good tutorial on .NET programming techniques or the C# language, please read Stan Lippman's C# Primer (Addison Wesley, 2002) or Jeffery Richter's Applied .NET Framework Programming (Microsoft Press, 2002) before taking on this book.

This book is divided into two volumes. Volume 1 focuses on the Common Language Runtime. Volume 2 will focus [ST3]on XML Web Services. Although the two technologies share a fair number of core concepts, the thought of covering them both in a single book made my head spin.

This book was written against Version 1 of the CLR. Some of the internal techniques used by the CLR may evolve over time and may in fact change radically. In particular, the details of virtual method dispatch are very subject to change. They are included in this book largely as an homage to COM developers wondering where the vptr went. That stated, the basic concepts that are the focus of this book are likely to remain stable for years to come.

Throughout the book, I use assertions in code to reinforce the expected state of a program. In the CLR, assertions are performed using System.Diagnostics.Debug.Assert, which accepts a Boolean expression as its argument. If the expression evaluates to false, then the assertion has failed and the program will halt with a distinguished error message. For readability, all code in this book uses the short form, Debug.Assert, which assumes that the System.Diagnostics namespace prefix has been imported.

My perspective on .NET is fairly agnostic with respect to language. In my daily life, I use C# for about 50 percent of my CLR-based programming. I use C++ for about 40 percent, and I resort to ILASM for the remaining 10 percent. That stated, most programming examples in this book use C# if for no other reason than it is often the most concise syntax for representing a particular concept or technique. Although some chapters may seem language-focused, none of them really is. The vast majority of this book could have used C++, but, given the tremendous popularity of C#, I elected to use C# to make this book as accessible as possible.

This book focuses on the Common Language Runtime and is divided into 10 chapters:

  • Chapter 1—The CLR as a Better COM: This chapter frames the discussion of the CLR as a replacement for the Component Object Model (COM) by looking at the issues that faced COM developers and explaining how the CLR addresses those issues through virtualization and ubiquitous, extensible metadata.

  • Chapter 2—Components: Ultimately, the CLR is a replacement for the OS and COM loaders. This chapter looks at how code is packaged and how code is loaded, both of which are done significantly differently than in the Win32 and COM worlds.

  • Chapter 3—Type Basics: Components are containers for the code and metadata that make up type definitions. This chapter focuses on the CLR's common type system (CTS), including what constitutes a type and how types relate. This is the first chapter that contains significant chunks of source code.

  • Chapter 4—Programming with Type: The CLR makes type a first-class concept in the programming model. This chapter is dedicated to the explicit use of type in CLR programs, with an emphasis on the role of metadata and runtime type information.

  • Chapter 5—Instances: The CLR programming model is based on types, objects, and values. Chapter 4 focused on type; this chapter focuses on objects and values. Specifically, this chapter outlines the difference between these two instancing models, including how values and objects differ with respect to memory management.

  • Chapter 6—Methods: All component interaction occurs through method invocation. The CLR provides a broad spectrum of techniques for making method invocation an explicit act. This chapter looks at those techniques, starting with method initialization through JIT compilation and ending with method termination via strongly typed exceptions.

  • Chapter 7—Advanced Methods: The CLR provides a rich architecture for intercepting method calls. This chapter dissects the CLR's interception facilities and its support for aspect-oriented programming. These facilities are one of the more innovative aspects of the CLR.

  • Chapter 8—Domains: The CLR uses AppDomains rather than OS processes to scope the execution of code. To that end, this chapter looks at the role of AppDomains both as a replacement for the underlying OS's process model as well as an AppDomain's interactions between the assembly resolver or loader. Readers with Java roots will find the closest analog to a Java class loader here.

  • Chapter 9—Security: One of the primary benefits of the CLR is that it provides a secure execution environment. This chapter looks at how the CLR loader supports the granting of privileges to code and how those privileges are enforced.

  • Chapter 10—CLR Externals: The first nine chapters of this book are focused on what it means to write programs to the CLR's programming model. This concluding chapter looks at how one steps outside of that programming model to deal with the world outside of the CLR.

    I l@ve RuBoard Previous Section Next Section