Hi,
I'm a bit confused about what you are trying to do here.
If you are trying to mock the object, and mean to set expectations on it, you can use this syntax (reflective mocks):
Mock<DerivedClass> myDerivedObject = MockManager.Mock<DerivedClass>();
myDerivedObject.ExpectAndReturn("MyString", "fakeValue");
Do note that you can set expectations on new methods OR overridden methods from MSCORLib. If this is not the case, you will not be able to set expectations on methods that are implemented in MSCORLib (ContextBoundObject is from there).
ObjectState is used for updating and retrieving values of non-public fields. So for instance, if your derived object looks like that:
public class DerivedClass: ContextBoundObject
{
private int myField=5;
...
}
You can set the field's value by using something like that:
DerivedClass newDerived = new DerivedClass();
ObjectState state = new ObjectState(newDerived);
state.SetField("myField", 3);
Assert.AreEqual(state.GetField("myField"), 3);
I ran a very basic test, containing a field in the derived object from ContextBoundObject, and it ran correctly. So assuming you do want to use ObjectState, can you post the whole code, so we can investigate?
Thanks.