This project is read-only.

Load an Assembly

CCI Metadata

FindGeneric operates on assemblies stored on the hard drive and uses DefaultHost as its host object. It loads each assembly that is listed in the command line by calling DefaultHost.LoadUnitFrom, as shown in the following example.
var assembly = host.LoadUnitFrom(assemblyName) as IAssembly;
if (assembly == null || assembly == Dummy.Assembly)
  Console.WriteLine("The file '" + assemblyName + "' is not a PE file" +
    " containing a CLR assembly, or an error occurred when loading it.");

LoadUnitFrom takes the input file path from the command-line arguments and returns an Assembly object that represents the assembly. However, LoadUnitFrom returns an IAssembly interface on the object, not the object itself. IAssembly is an immutable representation of an assembly, which provides a read-only view of the underlying Assembly object. Other CCI Metadata objects follow a similar pattern. The immutable version of the object is an interface, IObjectName, that consists of read-only versions of the object’s properties. For more discussion, see Mutable and Immutable Representations.

Next: Find Generic Methods
Return to Beginning

Last edited Jan 12, 2010 at 5:22 PM by Guy_Smith, version 2


No comments yet.