title: Method may only be called on a Type for which Type.IsGenericParameter is true
body: <p>I am getting this error on a routine which uses reflection to dump some object properties, something like the code below.</p>
  
  <pre><code>MemberInfo[] members = obj.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance) ;
  
  foreach (MemberInfo m in members)
  {
      PropertyInfo p = m as PropertyInfo;
      if (p != null)
      {
         object po = p.GetValue(obj, null);
  
         ...
      }
  }
  </code></pre>
  
  <p>The actual error is "Exception has been thrown by the target of an invocation"
  with an inner exception of "Method may only be called on a Type for which Type.IsGenericParameter is true."</p>
  
  <p>At this stage in the debugger obj appears as </p>
  
  <pre><code>  {Name = "SqlConnection" FullName = "System.Data.SqlClient.SqlConnection"} 
  </code></pre>
  
  <p>with the type System.RuntimeType</p>
  
  <p>The method m is {System.Reflection.MethodBase DeclaringMethod}  </p>
  
  <p>Note that obj is of type System.RuntimeType and members contains 188 items whereas a simple
  typeof(System.Data.SqlClient.SqlConnection).GetMembers(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance) only returns 65.</p>
  
  <p>I tried checking isGenericParameter on both obj and p.PropertyType, but this seems to be false for  most properties including those where p.GetValue works.</p>
  
  <p>So what exactly is a "Type for which Type.IsGenericParameter is true" and more importantly 
  how do I avoid this error without a try/catch?</p>