I’m trying this:
Type ThreadContextType = typeof(Application).GetNestedType('ThreadContext', System.Reflection.BindingFlags.NonPublic); MethodInfo FDoIdleMi = ThreadContextType.GetMethod('FDoIdle', BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[] { typeof(Int32) }, null);
ThreadContextType is ok but FDoIdleMi is null. I know there is something wrong in the GetMethod call because FDoIdle comes from the UnsafeNativeMethods.IMsoComponent interface.
How to do that? Thanks.
You need to fully-qualify the method name, because they’re using explicit interface implementation:
For the record, reflecting on non-public members is generally bad practice, but you probably already know that.
EDIT In the spirit of teaching a person to fish, I figured this out by calling
GetMethods(...)on the type object, and examining the returned array to see how the methods were named. Sure enough, the names included the complete namespace specification.