Reflection problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to reflect over some of the types inside System.Web.UI at runtime
to essentially clone them. The problem is that while fetching the type
returns me the appropriate Type object, calling Get... (member info) methods
always returns 0 items. Code is example listed below -- am i missing
something here?

Type t = Type.GetType("System.Web.UI.ResourceBasedLiteralControl,
System.Web, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a");

//this always returns 0 members
MemberInfo[] members =
t.GetMembers(BindingFlags.NonPublic|BindingFlags.FlattenHierarchy);
foreach(MemberInfo mi in members)
{
Console.WriteLine("Member : {0} - {1}", mi.Name, mi.ReflectedType.Name);
}


TIA,

_howard
 
ok - figured it out. I didn't realize that if you specify any access
modifier related binding flags, you also need to specify binding flags for
static/instance scope as well.

_howard
 
Back
Top