views:

91

answers:

2

Hi,

Im extending a class (DirectoryServices.AccountManagement.Principal) and I need to assign a value to a field in the base class but its marked internal. Can I use reflection to set the value? How would that be done?

I found this:

base.GetType().GetProperty("unpersisted").SetValue(??, false);

But im not quite sure how to give it the base Principal object

Any guidance is much appreciated.

A: 

use this for ??

JoelFan
I tried this but its the base class im interested in.
Exist
Sorry I take that back your correct, I just had to use GetField instead. Thanks!
Exist
accepted but downvoted?
JoelFan
A: 

GetProperty on the derived class and use all parameters as this:

GetType(Derived).GetProperty("BaseProperty", BindingFlags.Instance Or BindingFlags.NonPublic, Nothing, GetType(PropertyType), New Type() {}, Nothing).SetValue(DerivedInstance, NewValue, Nothing)
Wilhelm