Note
If a matching method could be found and the invocation itself has thrown an exception, then this method also throws an exception instead of returning .
public static bool TryInvokeMethod(
Object instance,
string methodName,
Type[]? genericParameters,
ReflectionWays way,
out Object?? result,
params Object?[]? parameters
)
Public Shared Function TryInvokeMethod (
instance As Object,
methodName As String,
genericParameters As Type(),
way As ReflectionWays,
<OutAttribute> ByRef result As Object,
ParamArray parameters As Object()
) As Boolean
public:
static bool TryInvokeMethod(
Object^ instance,
String^ methodName,
array<Type^>^ genericParameters,
ReflectionWays way,
[OutAttribute] Object^% result,
... array<Object^>^ parameters
)
static member TryInvokeMethod :
instance : Object *
methodName : string *
genericParameters : Type[] *
way : ReflectionWays *
result : Object byref *
parameters : Object[] -> bool
methodName can refer public and non-public methods. To avoid ambiguity this method gets all of the methods of the same name and chooses the first one for which the provided genericParameters and parameters match.
If you already have a MethodInfo instance use the InvokeMethod(Object, MethodInfo, Type, ReflectionWays, Object) method for better performance.
If way is Auto, then the DynamicDelegate way will be used.