Chapter 4: Assemblies

Overview

In this chapter we'll take a close look at assemblies, focusing in particular on the under-the-hood implementations of the basic concepts behind assemblies. I'm assuming you are familiar with the purpose of an assembly as well as related concepts such as metadata, modules, and the broad differences between public and shared assemblies, as well as basic techniques for compiling high-level code into assemblies - so we're going to go a bit beyond that and look at the underlying structure of assemblies and the Global Assembly Cache. In particular we'll cover:

  • PE Files - the concept of a portable executable file and how this concept has been extended to provide for assemblies.

  • Assembly Files - the types of file that can make up assemblies, and the high-level structures and information contained in them: modules, the prime module, resource-only PE files and other linked files.

  • Identity - the component parts of an assembly identity: the name, version, key, and culture. We'll examine how these are used.

  • Viewing Metadata - we'll briefly overview the main command-line tools that allow you to examine the information inside an assembly, as well as the two programmatic APIs for this purpose: the System.Reflection classes and the unmanaged reflection API.

  • The Global Assembly Cache (GAC) - the structure of the cache.

  • Probing - we'll examine the rules that determine where the runtime searches for assemblies and how to customize the probing rules for your applications.

  • Resources - how to compile resources and create satellite assemblies for localization purposes.

  • Assembly tools - we very briefly review the various command line tools that are available for generating and manipulating assemblies: al.exe, gacutil.exe, and so on.

We finish the chapter with a short example that demonstrates the process of creating a relatively complex assembly. The actual code for this assembly will be quite short, but I've designed the example so that the assembly contains code written in two high-level languages, as well as requiring localized and non-localized resources, and the assembly needs to be signed and placed in the GAC as well. We'll illustrate how to generate this assembly both from the command prompt and as far as possible using VS.NET.

I should also point out that there are a couple of topics concerning assemblies which I've postponed to later chapters because they tie in with other material that we haven't covered yet: the principles behind signing assemblies with a private key are covered in Chapter 13 once I've covered the necessary background in cryptography theory.

We start off now by examining the structure of a typical assembly, focusing on the PE and other files that might make up an assembly.



Advanced  .NET Programming
Advanced .NET Programming
ISBN: 1861006292
EAN: 2147483647
Year: 2002
Pages: 124

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net