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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.