battech
battech

Reputation: 833

MethodInfo showing null when getMethod is invoked with parameters containing reference type

 public abstract class DbAttribute : IComparable
 {
 }

public abstract bool GetString(DbAttribute attributeName, ref string attributeValue);

Assembly testAssembly = null;
Type attributeA = testAssembly.GetType("A.Core.Data.DbAttribute");   
Type elementA = testAssembly.GetType("A.Core.Data.DbElement");

MethodInfo mi = elementA.GetMethod("GetString", new Type[] { attributeA, typeof(System.String)});

mi is null event hough elementA.getMethods() show me the GetString method. I think i am doing something wrong with parameter attributeA.

If I use typeof(System.Object) instead of attributeA, still it returns null.

Please suggest how to use the GetMethod properly in this case.

Upvotes: 0

Views: 193

Answers (1)

feiyun0112
feiyun0112

Reputation: 771

I think it caused by ref parameter

MethodInfo mi =ElementA.GetMethod("GetString",new Type[] { typeof(AttributeA)  ,typeof(System.String).MakeByRefType()});

Upvotes: 3

Related Questions