Jerry Switalski
Jerry Switalski

Reputation: 2720

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?

Upvotes: 1

Views: 1334

Answers (1)

Zein Makki
Zein Makki

Reputation: 30032

Based on the comments, it seems the reference this._buildPhase is actually pointing to NULL and that's why you're getting this behavior.

Upvotes: 1

Related Questions