In order to read an assembly (i.e. to load it in memory and build the Code Object Model representation):
- Get an
System.Reflection.Assemblyinstance representing the assembly. - Create a PostSharp Domain.
- Load the Assembly in this domain using the
LoadAssemblymethod. 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;