jeudi 6 juin 2019

Unable to GetMethod() on inherited method

I have a base class that has a method named "GetAllKeys" which I'm attempting to invoke via reflection. The issue is that when I use GetMethod() the result is null.

var method = classType.GetMethod("GetAllKeys", BindingFlags.Public | BindingFlags.Static );

This is the signature of the method from the class.

public static IEnumerable<string> GetAllKeys()

Via the debugger I can see the method exists and has the following properties.

InvocationFlags = INVOCATION_FLAGS_INITIALIZED | INVOCATION_FLAGS_NEED_SECURITY
BindingFlags    Static | Public 
IsDynamicallyInvokable  true    
System.Runtime.InteropServices._MethodBase.IsHideBySig  true    
System.Runtime.InteropServices._MethodBase.IsPublic true    
System.Runtime.InteropServices._MethodBase.IsStatic true    

It looks like the HideBySig is a method attribute, so I can't use that in the GetMethod(), and I haven't had to do so in the past with other methods in the same inherited class.

What must I do to successfully retrieve this method for invocation?





Aucun commentaire:

Enregistrer un commentaire