Book review: Essential .NET, Volume I: The Common Language Runtime

Book data

  • Title: Essential .NET, Volume 1: The Common Language Runtime
  • Author: Don Box
  • ISBN: 0-201-73411-7

Review

The book starts of with discussing the evolution of component technologies from Microsoft and how .NET was conceived to solve the problems with COM. After this short introductory chapter, the author continues with discussing .NET.

The second chapter shows how code is packaged in the .NET framework by discussing modules and assemblies. It then continues to discuss the visibility of types in an assembly, assembly names, assembly loading and the related issues of resolving assembly location and version.

The third chapter discusses types in the .NET framework. It starts off with how to define types and continues with fields, methods and nested types. After a short discussion of static constructors he describes inheritance: interface inheritance and base types. During the discussion of base type inheritance he also provides some insights on its influence on methods with the same name.

The fourth chapter is about “Programming with Type” and starts of with a more or less detailed introduction about how types are represented inside the CLR implementation (google for CORINFO_CLASS_STRUCT and you will get an idea of the level of detail) and how this enables casting between types. He then continues with metadata and reflection, special methods like properties and events and extending the metadata of a type with attributes.

After this discussion about how to make types chapter five discusses using types to make instances. It starts with the classical reference versus value type comparison and their different semantics when using them as variables, parameters and fields inside objects. He then continues with the difference between object equivalence and object identity and its relation with comparing objects and cloning objects. The chapter finishes with some quick notes on boxing, arrays, the object lifecycle (root references and non root references and their relation to garbage collection) and finalization.

These first chapters have a lot of overlap with Jeffrey Richters book “Applied Microsoft .NET Framework programming”. The fourth chapter has a more thorough discussion on the internal representation of types in the CLR implementation by introducing the CORINFO_CLASS_STRUCT structure.

Chapter 6 discusses methods. Like chapter 4, it starts of with how the CLR implementation threats methods discussing JIT compilation and method tables. He then continues with method invocation and how virtual method dispatching is implemented. The next sections discuss method invocation by reflection (using MethodInfo), delegates and asynchronous method invocation. The last section of this chapter is about ways to leave a method: exceptions and return statement.

Chapter seven provides a very thorough discussion on handling method invocation as message passing. It starts of with a motivation for the technique (like enabling aspect oriented programming) and then gradually digs deeper and deeper into the subject. It discusses the interfaces involved in transforming a method call to a message, the proxies involved, how to attach your own messagesinks and add your own data to the call using “context”.

These two chapters about method invocation are, with the net chapter, to me, what makes this book worth reading. They provide information not available in Richter’s book and present it in an understandable, practical fashion. By providing the motivation intro and gradually giving more info he subject is presented in an accessible format.

Chapter eight discusses Domains. It begins with what they are and how they relate to execution scope. Following is about using AppDomains in your programs, monitoring them with the events they expose and influencing their behavior for assembly resolving and loading by their properties. Next is a discussion on cross AppDomain calls and marshalling.

Again, this chapter provides some information not found in Richters book, all though there is again some overlap between the two.

The one to final chapter is about security in the .NET framework and discusses the various components and classes that together provide the security model of the framework:

  • Evidence: types of evidence (Site, Url, etc…) and certificate authorities (like VeriSign).
  • Policy: plicy levels, permission sets and code groups.
  • Permissions
  • Enforcement

You can find a similar online version of this chapter at The Security Infrastructure of the CLR Provides Evidence, Policy, Permissions, and Enforcement Services. The subject is completely new to me and I found the books chapter hard to follow.

The last chapter in the book is on CLR externals and discusses things like integration of the CLR with unmanaged code: handling of unmanaged memory with respect to the garbage collector, in memory member alignment and executing unmanaged code in the CLR: P/Invoke. The final sections are on hosting the CLR in your application.

Conclusion

As stated above, there is a some overlap with Jeffrey Richter’s book on .NET Framework Programming, but there is enough difference to justify buying and reading both books.

Where Richter’s book provides a more thorough discussion on the elemental .NET Framework constructs, this book provides a more thorough discussion on the more specialized constructs like the different forms of method invocation.

However, I do wonder if his discussions on how some constructs get implemented in the CLR implementation are of any real value? He says himself that the information is retrieved by experimentation and can be changed in the future. Secondly, all though they give the impression of digging deep into the subject, I feel that they are only scratching the surface of how things are implemented. So they are somewhere in between too much detail for the discussion at hand, and not enough detail to gain real insight into the CLR implementation. I also wonder if anyone reading this book really cares? If you do, you would probably read Shared Source CLI Essentials.

What I didn’t like about the book is that their is no guidance. It’s a summary of the How, but unlike Richter’s book, doesn’t really discuss the Why, or the How Better.

I definitely recommend this book but would not suggest it as a first read on .NET. I read Richter’s book first and immediately followed it by this one. And I’m glad I read them in this order. If you would have to choose between the two books however, pick Richter’s book.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s