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

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

When overridden in a derived class, sets the value of the field with the specified constraints on type conversion.

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


Public MustOverride Sub SetValue ( _
    obj As Object, _
    value As Object, _
    invokeAttr As BindingFlags, _
    binder As Binder, _
    culture As CultureInfo _
public abstract void SetValue(
    Object obj,
    Object value,
    BindingFlags invokeAttr,
    Binder binder,
    CultureInfo culture



Exception Condition

The field is not accessible.


The obj parameter is nullNothingnullptra null reference (Nothing in Visual Basic) and the field is an instance field.


The field does not exist on the object.


The value parameter cannot be converted and stored in the field.


The member is invoked late-bound through mechanisms such as Type..::.InvokeMember.


In Windows Phone apps, only accessible fields can be set using reflection.

This method will assign value to the field reflected by this instance on obj. If the field is static, obj will be ignored. For nonstatic 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 is of type Boolean, the new value must be boxed as an instance of Object.

Version Notes

Windows Phone

SetValue throws an ArgumentNullException exception instead of a TargetException exception when obj is nullNothingnullptra null reference (Nothing in Visual Basic).

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0


Windows Phone

See Also


FieldInfo Class

SetValue Overload

System.Reflection Namespace