Freigeben über


FieldBuilder.SetValue Method (Object, Object, BindingFlags, Binder, CultureInfo)

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

Sets the value of the field supported by the given object.

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

Syntax

'Declaration
Public Overrides Sub SetValue ( _
    obj As Object, _
    val As Object, _
    invokeAttr As BindingFlags, _
    binder As Binder, _
    culture As CultureInfo _
)
public override void SetValue(
    Object obj,
    Object val,
    BindingFlags invokeAttr,
    Binder binder,
    CultureInfo culture
)

Parameters

  • obj
    Type: System.Object
    The object on which to access the field.
  • invokeAttr
    Type: System.Reflection.BindingFlags
    A member of IBinder that specifies the type of binding that is desired (for example, IBinder.CreateInstance, IBinder.ExactBinding).
  • binder
    Type: System.Reflection.Binder
    A set of properties and enabling for binding, coercion of argument types, and invocation of members using reflection. If binder is null, then IBinder.DefaultBinding is used.

Exceptions

Exception Condition
NotSupportedException

This method is not supported.

Remarks

Important noteImportant Note:

This method is currently not supported. As a workaround, retrieve the FieldInfo by reflecting on the finished type and call SetValue to set the value of the field.

This method will assign the val parameter to the field reflected by this instance on Objectobj. If the field is static, obj will be ignored. For non-static fields, obj should be an instance of a class that inherits or declares the field.

The new value is passed as an Object. For example, if the field's type is Boolean, an instance of Object with the appropriate Boolean value is passed.

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.