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 happen...



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.

Michael


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to