[Ironpython-users] How to call parameterless overload of generic method?

Jeff Hardy jdhardy at gmail.com
Fri Dec 19 23:36:25 CET 2014


On Fri, Dec 19, 2014 at 12:38 PM, Markus Schaber <m.schaber at codesys.com> wrote:
> Hi,
>
> The attached C# file demonstrates a small problem we currently encountered using IronPython 2.7.4:
>
> We have a C# method which has two overloads - one is parameterless, and the other one has a single out parameter.
>
> For non-generic methods, it is possible to call both variants when calling with and without clr.Reference, but this does not work for generic methods.
>
> When trying to call the parameterless generic method directly, the following exception appears:
>
> Microsoft.Scripting.ArgumentTypeException was unhandled
>   HResult=-2146233088
>   Message=Multiple targets could match: Method(), Method()
>   Source=Microsoft.Dynamic
>   StackTrace:
> [snipped]
>
> The workaround is to use the .Overloads[] syntax:
>
> print instance.Method[str].Overloads[()]()

Probably just a bug in the generic method binder. You're into *really*
edge case territory there. :) If you can proved C# signatures that
work and don't work, and the IronPython code used to call them, it
would be helpful.

- Jeff


More information about the Ironpython-users mailing list