mardi 30 août 2016

FieldInfo.GetValue returns null

I have this piece of code:

FieldInfo fi = this.GetType().GetField(StringConstants.UNDERSCORE + phase, BindingFlags.Instance | BindingFlags.NonPublic);

    if (fi != null)
    {
        itemPhase = fi.GetValue(this) as IItemPhase;
    }

    if (itemPhase != null) 
    {
        _currentPhase = phase;
        _itemVo.Phase = phase;
        itemPhase.PreparePhase();
    }

FieldInfo fi gets correct value, so the field was found.

enter image description here

But FieldInfo.GetValue returns always null:

enter image description here

... and the Type matches:

enter image description here

Anyone knows why?





Aucun commentaire:

Enregistrer un commentaire