Prepares a method for inclusion in a constrained execution region (CER) with the specified instantiation.
You can provide generics support for compilers by using the RuntimeHelpers.PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[]) method. The common language runtime cannot prepare constrained execution regions (CERs) rooted in a method that has generic type parameters (either a type parameter on the class containing the method or one on the method itself) when those type parameters are instantiated as reference types.
You can use this overload to pass a specific instantiation (such as an array of types), specifying class type parameters first (if any), followed by method type parameters (if any). The runtime prepares that instantiation of the method. (This is necessary only if the instantiations you use contain at least one reference type parameter.) Thus, you can use a CER-style try clause in a generic method (or a nongeneric method on a generic class) and it will work reliably with instantiations of int or other value types. To instantiate reference types such as string, you must use an explicit RuntimeHelpers.PrepareMethod(RuntimeMethodHandle, RuntimeTypeHandle[]) method on the CER root method first.