In order to read an assembly (i.e. to load it in memory and build the Code Object Model representation):

  1. Get an System.Reflection.Assembly instance representing the assembly.
  2. Create a PostSharp Domain.
  3. Load the Assembly in this domain using the LoadAssembly method. This method returns an AssemblyEnvelope and the principal module is on the AssemblyEnvelope.ManifestModule property.

The following line of codes load an assembly and give its principal module:

Assembly assembly = Assembly.GetCallingAssembly();
Domain domain = new Domain();
ModuleDeclaration module = domain.LoadAssembly(assembly).ManifestModule;