Chapter 31. Assemblies and Reflection

WHAT YOU WILL LEARN IN THIS CHAPTER

  • What assemblies are and how they are used

  • The general structure of an assembly

  • How assemblies can be versioned

  • The global assembly cache (GAC), including how and when to use it

  • How assemblies are located and loaded by the CLR

  • Using reflection to inspect assemblies in order to determine the types they contain and the interfaces of those types

  • Dynamic loading of assemblies, allowing your application to inject functionality that was not available at compile time

By now, you've probably developed some programs in .NET, so you've seen the modules produced by the .NET compilers, which have file extensions of .dll or .exe. Most .NET modules are DLLs, including class libraries and those that serve as code-behind for ASP.NET. Windows applications, console applications, and Windows Services are examples of .NET modules that are executables and thus have an extension of .exe.

These .NET-compiled modules, both DLLs and EXEs, are referred to as assemblies. Assemblies are the unit of deployment in .NET, containing both compiled code and metadata that is needed by the .NET common language runtime (CLR) to run the code. Metadata includes information such as the code's identity and version, dependencies on other assemblies, and a list of types and resources exposed by the assembly.

Basic development in .NET doesn't require you to know any more than that. However, as your applications become more complex, and as you begin considering ...

Get Professional Visual Basic® 2010 and .NET 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.