Module is a concept of component that composes an assembly.
it has a file name extention of "netmodule".
Generate a module:
csc /t:module Stringer.cs
/t: indicates the compiler to generate a module rather than an assembly. Stringer.netmodule is produced. A module can be added to an assembly.
Create references between modules
the following line creates a module with reference to another module:
csc /addmodule:Stringer.netmodule /t:module Client.cs
Create multifile assembly
The following line create a two file assmbly:
csc /out:Client.exe Client.cs /out:Stringer.netmodule Stringer.cs
In addition to modules, an assembly has manifest information (meta data).
Assembly Linker (al.exe) is used to create a assembly from a collection of modules
al Client.netmodule, Stringer.netmodule /main:TheClassName.Main /out:MyAssembly.exe /target:exe
Aside from "exe", the target can be "win" and "lib"
MSIL Disassembler
.Net tool ildasm.exe (MSIL Disassembler) can examine the content and recognize a module or an assembly.
Reflecting module info with reflection code
(source:
http://msdn2.microsoft.com/en-us/library/system.reflection.module.aspx)
using System.Reflection;
using System;
public class Program {
public static void Main() {
Class1 c1 = new Class1();
// Show the current module.
Module m = c1.GetType().Module;
Console.WriteLine("The current module is {0}.", m.Name);
// List all modules in the assembly.
Assembly curAssembly = Assembly.GetExecutingAssembly();
Console.WriteLine("The current executing assembly is {0}.", curAssembly);
Module[] mods = curAssembly.GetModules();
foreach (Module md in mods) {
Console.WriteLine("This assembly contains the {0} module", md.Name);
}
Console.ReadLine();
}
}
class Class1 {
}
Monday, December 24, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment