System.Reflection.MethodBody Class

Provides access to the metadata and MSIL for the body of a method.

See Also: MethodBody Members


public class MethodBody


The System.Reflection.MethodBody class provides access to information about the local variables and exception-handling clauses in a method body, and to the Microsoft intermediate language (MSIL) that makes up the method body.

You can use the token-resolution methods of the module class, such as Module.ResolveType(int, Type[], Type[]), Module.ResolveMethod(int, Type[], Type[]), and Module.ResolveType(int, Type[], Type[]), to resolve the tokens in the method body to Type objects, System.Reflection.MethodInfo objects, and System.Reflection.FieldInfo objects that provide detailed information about the types, methods, and fields accessed by the MSIL in the method body.


Parsing method bodies requires a thorough understanding of metadata and MSIL instruction formats. Information can be found in the Common Language Infrastructure (CLI) documentation, especially "Partition II: Metadata Definition and Semantics" and "Partition III: CIL Instruction Set". The documentation is available online; see tp:// on MSDN and tp:// on the Ecma International Web site.

To obtain a System.Reflection.MethodBody object for a given method, first obtain a System.Reflection.MethodInfo object for the method, then call the System.Reflection.MethodInfo object's MethodBase.GetMethodBody method.


Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions:,
Since: .NET 2.0