When overridden in a derived class, gets a MethodBody object that provides access to the MSIL stream, local variables, and exceptions for the current method.
Assembly: mscorlib (in mscorlib.dll)
[<ReflectionPermissionAttribute(SecurityAction.Demand, Flags = ReflectionPermissionFlag.MemberAccess)>] abstract GetMethodBody : unit -> MethodBody [<ReflectionPermissionAttribute(SecurityAction.Demand, Flags = ReflectionPermissionFlag.MemberAccess)>] override GetMethodBody : unit -> MethodBody
This method is invalid unless overridden in a derived class.
You do not have to override the in order to use it. You can call the method on MethodInfo and ConstructorInfo objects, because the method is overridden in the runtime versions of these classes. For example, the runtime version of the MethodInfo class derives from the MethodInfo class, which in turn derives from the MethodBase class.
The following code example defines a test method named MethodBodyExample and displays its local variable information and exception-handling clauses. The method is used to obtain a MethodBody object for the test method.
The LocalVariables property is used to obtain a list of LocalVariableInfo objects and display their types and index order. The ExceptionHandlingClauses property is used to obtain a list of exception-handling clauses.
Not all computer languages can generate ExceptionHandlingClauseOptions.Filter clauses. The Visual Basic example shows a filter clause, using a Visual Basic When expression, which is omitted from the examples for other languages.