chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
I am trying to set a private field with the Object State object but I keep getting a null reference exception. This is the code.

Operation activity = processFactory.CreateProcess("TestProcess");

ObjectState operationState = new ObjectState(activity);

operationState.SetField("_status", status);



Line 3 of the code is where the exception occurs. I have verified that there is a private field called "_status". I think this may be happening because the factory actually creates an object of type Process which is a sub type of Operation. I believe that you can not directly access the private fields of a parent class with reflection. I dont know the internals of how your are setting the field but what I have done in the past is just looped through the type's base classes until I found the specified field.

Or maybe this is another problem. Thanks for any help.
asked by jnapier (9.6k points)

2 Answers

0 votes
Hi,

This is a BUG :twisted:

Actually its 2 Bugs :evil:

The first is as you said that ObjectState doesn't deal with private fields in a base class. The second is the bad error message...

We will check it and post a fix
answered by scott (32k points)
0 votes
A fix has been delivered offline and will be part of our next patch (3.0.1) 8)
answered by scott (32k points)
...