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

Markus Schaber m.schaber at codesys.com
Fri Dec 19 13:38:05 CET 2014


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[()]()


Btw, trying "print instance.Method[str].Overloads[int]()" leads to the following funny ArgumentTypeException: "Method() takes at least 2147483647 arguments (0 given)"



Best regards

Markus Schaber

CODESYS® a trademark of 3S-Smart Software Solutions GmbH

Inspiring Automation Solutions

3S-Smart Software Solutions GmbH
Dipl.-Inf. Markus Schaber | Product Development Core Technology
Memminger Str. 151 | 87439 Kempten | Germany
Tel. +49-831-54031-979 | Fax +49-831-54031-50

E-Mail: m.schaber at codesys.com | Web: http://www.codesys.com | CODESYS store: http://store.codesys.com
CODESYS forum: http://forum.codesys.com

Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner | Trade register: Kempten HRB 6186 | Tax ID No.: DE 167014915

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received
this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure
or distribution of the material in this e-mail is strictly forbidden.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Program.cs
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20141219/dadd14dd/attachment.ksh>


More information about the Ironpython-users mailing list