"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uQ**************@TK2MSFTNGP09.phx.gbl...
Mike,
An assembly can contain many modules. Ultimately though, an assembly
is ONE file, with ONE manifest.
No, that's not true. (Well, the one manifest part is true.)
See, for instance,
http://www.dnzone.com/ShowDetail.asp?NewsId=698, which
says
What is an assembly?
* An Assembly is a logical unit of code
* One assembly can contain one or more files :
There is one *main* file in as assembly, the one that contains the assembly
manifest. But it can refer to an arbitrary number of other files, all of
which are part of the assembly. To see this, do the following:
Link some C# classes into a module. It doesn't really matter what's in
them.
Link the following class into an executable, adding in the module created in
the previous step: (The command line looks like
"csc /addmodule:Package.netmodule Hello.cs" )
using System;
using System.IO;
using System.Reflection;
class Hello {
public static void Main()
{
try {
Assembly assm = Assembly.GetAssembly(typeof(Hello));
FileStream[] files = assm.GetFiles();
Console.WriteLine("" + files.Length + " files in assembly");
foreach (FileStream f in files) {
Console.WriteLine(f.Name);
}
}
catch (Exception ex) {
Console.WriteLine(ex);
}
}
}
Run it. You'll see output like:
2 files in assembly
c:\csharp\Hello.exe
c:\csharp\package.netmodule
Now delete the file containing the module. Try to run the executable again,
and you'll see an error like:
System.IO.FileNotFoundException: File or assembly name Package.netmodule,
or one
of its dependencies, was not found.
File name: "Package.netmodule"
at System.Reflection.Assembly.nGetModules(Boolean loadIfNotFound,
Boolean getResourceModules)
at System.Reflection.Assembly.GetFiles(Boolean getResourceModules)
at System.Reflection.Assembly.GetFiles()
at Hello.Main()
The error being that one of the assembly's files is missing.