MethodBuilder.Invoke Method (Object, BindingFlags, Binder, array<Object[], CultureInfo)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Dynamically invokes the method reflected by this instance on the given object, passing along the specified parameters, and under the constraints of the given binder.

Namespace:  System.Reflection.Emit
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overrides Function Invoke ( _
    obj As Object, _
    invokeAttr As BindingFlags, _
    binder As Binder, _
    parameters As Object(), _
    culture As CultureInfo _
) As Object
public override Object Invoke(
    Object obj,
    BindingFlags invokeAttr,
    Binder binder,
    Object[] parameters,
    CultureInfo culture
)

Parameters

  • obj
    Type: System.Object
    The object on which to invoke the specified method. If the method is static, this parameter is ignored.
  • binder
    Type: System.Reflection.Binder
    An object that enables the binding, coercion of argument types, invocation of members, and retrieval of MemberInfo objects via reflection. If binder is nulla null reference (Nothing in Visual Basic), the default binder is used. For more details, see Binder.
  • parameters
    Type: array<System.Object[]
    An argument list. This is an array of arguments with the same number, order, and type as the parameters of the method to be invoked. If there are no parameters this should be nulla null reference (Nothing in Visual Basic).
  • culture
    Type: System.Globalization.CultureInfo
    An instance of CultureInfo used to govern the coercion of types. If this is null, the CultureInfo for the current thread is used. (Note that this is necessary to, for example, convert a String that represents 1000 to a Double value, since 1000 is represented differently by different cultures.)

Return Value

Type: System.Object
An object that contains the return value of the invoked method.

Exceptions

Exception Condition
NotSupportedException

This method is not currently supported. Retrieve the method by using Type.GetMethod on the completed type, and then use the MethodBase.Invoke method; or call Type.InvokeMember on the completed type.

Remarks

If the method is static, the obj parameter is ignored. For non-static methods, obj should be an instance of a class that inherits or declares the method and must be the same type as this class. If the method has no parameters, the value of parameters should be nulla null reference (Nothing in Visual Basic). Otherwise, the number, type, and order of elements in the parameters array should be identical to the number, type, and order of parameters for the method reflected by this instance.

NoteNote:

Access restrictions are ignored for fully trusted code. That is, private constructors, methods, fields, and properties can be accessed and invoked using reflection whenever the code is fully trusted.

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.