[IronPython] CallTarget0 problem

Michael Foord fuzzyman at voidspace.org.uk
Thu Jun 4 21:30:23 CEST 2009

Kent Johnson wrote:
> Hi,
> I am an IPy newbie, trying to run example 7.17 from IronPython in
> Action. It includes the code
> delegate = CallTarget0(something.form.Close)
> something.form.Invoke(delegate)
> were something.form is a Windows.Forms.Form object. The first line
> above gives this error:
> Traceback (most recent call last):
>   File "C:\Project\MangoTest\src\SmokeTest.py", line 43, in
> C:\Project\MangoTest\src\SmokeTest.py
>   File "mscorlib", line unknown, in CreateDelegate
> ValueError: Error binding to target method.

A while ago there were changes to CallTarget0 that made it incompatible 
with .NET methods that have a void return signature. Dino told me he 
would change it back so it would work again, but I guess that didn't 

> If I change the first line to
>   delegate = CallTarget0(lambda: something.form.Close())
> it works fine.

This is the correct change to fix it.

> Does the argument to CallTarget0() have to be a Python function? Or,
> what is going on here?

No - but it is methods with a void return signature that are the issue.



More information about the Ironpython-users mailing list