I am getting this error on a routine which uses reflection to dump some object properties, something like the code below.
MemberInfo[] members = obj.GetType(
All the clues are in there. The type of the obj is the Type
class itself (or rather the strange RuntimeType derivative).
At the point of failure you loop has arrived the Type
class property called DeclaringMethod. However the type that this instance of the Type
class is describing is System.Data.SqlClient.SqlConnection
which is not a Generic Type of a method.
Hence attempting to invoke the get on DeclaringMethod results in the exception.
The key is you are examining the type of the class Type
. Its a bit circular but think of this:-
SqlConnection s = new SqlConnection();
Type t = s.GetType()
Type ouch = t.GetType()
What is class ouch describing?