Book: Advanced .NET Programming
This is a book about getting the best out of .NET. It is based on the philosophy that the best approach to writing good, high-performance, robust applications that take full advantage of the features of .NET is to understand what’s going on deep under the hood. This means that there are chapters that explore the .NET internals and in particular Common Intermediate Language (CIL), as well as chapters with a very practical basis, covering how to use specific technologies such as threading, dynamic code generation, and WMI.
This book is not a purely theoretical book for geeks, nor is it one of those purely problem-solving books that tells you how to write some code to do something without explaining how and why it works. Rather, I have sought to combine the twin aspects of practical technology-specific applications and diving under the hood of the CLR, in the belief that the true advanced .NET developer needs both. So a lot of the book is devoted to diving deep under the covers of .NET. We go way beyond the MSDN documentation in places – and generally beyond most other .NET books presently available. But we never go into some abstract feature just for the sake of it. There is always a background focus on the fact that understanding this CLR implementation detail can in some way help you to write better code. And there are a lot of chapters that show you how to write better applications in specific areas such as Windows Forms, how to take advantage of .NET features such as security, or how to better debug your code or optimize it for performance.
Just as it says on the cover, this is a book about advanced .NET programming. It’s a book for people who are already familiar with the principles of writing applications targeted at the .NET Framework and who want to understand more. This will perhaps be to get an idea of exactly what the JIT compiler is looking for when it assesses whether your code is type-safe. Perhaps to be able to look at the CIL emitted by your compiler so you can understand some of the optimizations and use the knowledge to write better performing code. Or perhaps because you need to use some of the more advanced features of .NET in your code, such as dynamic code generation, or you need more information about setting up security for or for deploying your code.
The advanced nature of this book is illustrated by the fact that the very first thing we do, in Chapters 1-2, is to start learning Intermediate Language (IL). There’s no way out of that if you really want to get the best from this book – we need it so we can look at how certain high-level language features of VB, C#, and C++ work under the hood.
The fact that this is an advanced book means that I won’t spend any time telling you any of the basics of .NET, other than occasionally in the form of a quick background review. So for example, if you don’t yet know what a JIT compiler is, or what the difference between a value and reference type is, then this is not the book for you – because I assume you already know all that that. Similarly, I assume that you are fluent in at least one high-level .NET-compliant language, such as Managed C++, Visual Basic .NET, or C#. In order to read this book you should also be comfortable with the principles of implementation-inheritance-based object-oriented programming.
As an example, one of the areas we cover in the book is assemblies. If you want to understand why Microsoft introduced the concept of the assembly, what metadata is, or how assemblies solve versioning issues and enable all the information needed to use the assembly in one place, you won’t find that information in this book. There are already lots of books on the market that will give you that kind of information. Since this is an advanced book, we assume you already know all that stuff. Instead, our chapter about assemblies starts by presenting the binary format for an assembly – reviewing how the IL code and metadata is laid out in it, and how this helps with performance. Then it goes on to look at how you can extract information and metadata from the assembly programmatically, following up with how you can use assemblies and resources in your assemblies to make sure your applications are correctly localized and ready for those world-wide sales you’re looking for.