Namespace: System.Reflection.Portable
Provides types for reading and manipulating portable executable (PE) files, which are the standard executable file format for Windows. This namespace is crucial for advanced reflection scenarios that involve inspecting or modifying the structure of assemblies at a low level.
Classes
Class: Assembly
Represents a portable executable file loaded into memory. This class provides access to metadata, sections, and other low-level details of an assembly.
Methods
GetTypes()
public IEnumerable<TypeInfo> GetTypes()
- An enumerable collection of
TypeInfo
objects representing all types defined within the assembly.
var assembly = Assembly.LoadFile("MyAssembly.dll");
foreach (var type in assembly.GetTypes())
{
Console.WriteLine($"Found type: {type.Name}");
}
Properties
Name
public string Name { get; }
Gets the simple name of the assembly.
Properties
Version
public Version Version { get; }
Gets the version information of the assembly.
Class: Module
Represents a single module within a portable executable file.
Properties
Name
public string Name { get; }
Gets the name of the module.
Class: MethodInfo
Represents metadata for a method or constructor defined in a portable executable.
Properties
Name
public string Name { get; }
Gets the name of the method.
Properties
ReturnType
public TypeInfo ReturnType { get; }
Gets the return type of the method.
Class: TypeInfo
Represents metadata for a type defined in a portable executable.
Properties
FullName
public string FullName { get; }
Gets the fully qualified name of the type.
Properties
Namespace
public string Namespace { get; }
Gets the namespace of the type.
Properties
Methods
public IEnumerable<MethodInfo> Methods { get; }
Gets a collection of methods defined for this type.
Class: FieldInfo
Represents metadata for a field defined in a portable executable.
Properties
Name
public string Name { get; }
Gets the name of the field.
Properties
FieldType
public TypeInfo FieldType { get; }
Gets the type of the field.