[Mono-dev] Patch to add support to execute methods with ParamArray thought Reflection
Mario Chavez
mario.chavez at gmail.com
Thu Oct 25 02:31:17 EDT 2007
This new diff fix a issue with boo, the problem is related to methods with
zero parameters but parameters are passed when calling SelectMethod in
Binder.cs
Mario
On 10/24/07, Mario Chavez <mario.chavez at gmail.com> wrote:
>
> Hi;
>
> Currently reflection does not support methods that have ParamArray
> attribute to be called with InvokeMember, like:
>
> ... some class
> public static void TestMethod(params string[] param1)
> {
> Console.WriteLine("Test Method 3, one params");
> }
> .... some class
>
> Type type = typeof(ParamArrayTest);
> object obj = type.InvokeMember("TestMethod", InvokeBindingFlags,
> null, null, new object[] {"param1"});
>
> it fails with:
>
> Unhandled Exception: System.MissingMethodException: The best match for
> method TestMethod has some invalid parameter.
> at System.MonoType.InvokeMember (System.String name, BindingFlags
> invokeAttr, System.Reflection.Binder binder, System.Object target,
> System.Object[] args, System.Reflection.ParameterModifier[] modifiers,
> System.Globalization.CultureInfo culture, System.String[] namedParameters)
> [0x00000]
> at System.Type.InvokeMember (System.String name, BindingFlags
> invokeAttr, System.Reflection.Binder binder, System.Object target,
> System.Object[] args) [0x00000]
> at ParamArrayTest.Main (System.String[] args) [0x00000]
>
> This patch for Binder.cs and MonoType.cs allows this type of calling,
> which by the way does work on MS .NET
>
> I hope that this patch is good enough to go into Mono
>
> Thanks
> --
> Mario Chavez
> mario.chavez at gmail.com
> http://mario-chavez.blogspot.com/
>
--
Mario Chavez
mario.chavez at gmail.com
http://mario-chavez.blogspot.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071024/f9b6daf8/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: paramarray.diff
Type: application/octet-stream
Size: 4195 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071024/f9b6daf8/attachment.obj
More information about the Mono-devel-list
mailing list