There are several ways to go about creating an assembly. The first method, using Visual Studio, you should already be quite familiar with. Every time you have created a solution so far in this book, you have created an assembly. When you create a "Class Library" project within Visual Studio, the output of that Class Library is an assembly with the .DLL extension.
The other way to create an assembly is to use the Assembly Linker tool, AL.EXE. This tool provides a command-line interface to linking multiple compiled modules into an assembly. In fact, this is the only way for you to create a multimodule assembly in C#, as opposed to VB.NET, which allows for the creation of multiple modules per assembly directly within Visual Studio.
You can also use; Reflection to obtain information about an assembly. Listing 12.1 shows how you can retrieve some basic information from the assembly's manifest using the Assembly class.
Listing 12.1. Using the Assembly Class
You can also use the Assembly class to load and obtain information from other assemblies. If you add a "Class Library" project to the preceding sample, you can modify the code so it reads information from the compiled DLL in addition to the executable file. This is illustrated in Listing 12.2.
Listing 12.2. Loading an External Assembly
When you run this application, after having created an empty class library called SampleAssembly and adding a reference to that project from the main project, you get the following output:
Current Assembly AssemblyDemo1 loaded from C:\Documents and Settings\Kevin\My Do cuments\Writing\SAMS\C# 2005 Unleashed\12\Code\AssemblyDemo1\AssemblyDemo1\bin\D ebug\AssemblyDemo1.exe Loaded from the Global Assembly Cache? False This Assembly requires version v2.0.50727 of the runtime Other Assembly: SampleAssembly Types contained in SampleAssembly Class1