8 June, 2009
0 Comments
0 categories
I used the Type.BaseType method to get to the private instance fields of a extended Microsoft ReportViewer Control.
public object GetParametersArea(ExtendedReportViewer viewer)
{
return viewer.GetType().BaseType.GetField("m_parametersArea", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(viewer);
}
You can’t use the bindingflag option BindingFlags.FlattenHierarchy, because this option does not include private members (http://msdn.microsoft.com/en-us/library/6ztex2dc.aspx)
Solution found at: http://stackoverflow.com/questions/686482/c-accessing-inherited-private-instance-members-through-reflection
Tags: C#