Skip to Main Content
C# in a Nutshell
book

C# in a Nutshell

by Ben Albahari, Ted Neward, Peter Drayton
March 2002
Intermediate to advanced content levelIntermediate to advanced
864 pages
31h 8m
English
O'Reilly Media, Inc.
Content preview from C# in a Nutshell

Name

MethodRental

Synopsis

This class can be used to swap a method “body” (the MSIL code inside the method). To do this, use the static SwapMethodBody() method, and specify the target Type, the token of the method that should receive the new body, a pointer to the new method, the size of the new method, and a flag specifying the type of compilation using the appropriate field constant (either JitImmediate or JitOnDemand). The IntPtr to the new method body should point to an array of bytes that contain the IL for the method’s header and body.

public sealed class MethodRental {
// Public Static Fields
   public const field int JitImmediate;                          // =1
   public const field int JitOnDemand;                           // =0
                  // Public Static Methods
   public static method void SwapMethodBody(Type cls, 
        int methodtoken, IntPtr rgIL, int methodSize, 
        int flags);  
}
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# 8.0 in a Nutshell

C# 8.0 in a Nutshell

Joseph Albahari, Eric Johannsen
C# 10 in a Nutshell

C# 10 in a Nutshell

Joseph Albahari
C# in a Nutshell, Second Edition

C# in a Nutshell, Second Edition

Peter Drayton, Ben Albahari, Ted Neward
Code like a Pro in C#

Code like a Pro in C#

Jort Rodenburg

Publisher Resources

ISBN: 0596001819Catalog PageErrata