Late Binding - Help invoking a method please.

Jun 19 2008 1:48 PM

Hi,

I am using reflection / late binding to invoke a method.  This all works correctly as long as my paramater types match exactly the parameter types for the method.

However I need it to attempt to parse the supplied parameters and convert their types to match that of the method being invoked.  I guess its possible through setting some flags on the Binder ??  however I cannot get this to work.

 

Here is my code so far (which will error if an incorrect paramater type is passed)

object[] methodParams = { "x", "y" };

Type thisType = this.GetType();

MethodInfo methodToCall = thisType.GetMethod("MyMethod");

methodToCall.Invoke(this, methodParams);

 


Answers (2)