[IronPython] bugs with event handlers in 1.1 and 2.0 alpha 5

Toni Alatalo antont at kyperjokki.fi
Mon Nov 5 15:31:42 CET 2007


when making a scripting system with IronPython in an embedded context I 
encountered first a bug in 1.1 in re-adding event handlers that had been 
cleared in-between (I wanted that to be able to refresh the py written 
handlers on the fly) - that is reported as bug #13685 

While making the test case for that I came across a different problem in 
2.0 alpha 5: [#13687] Registering c#-written methods as event handlers 
from ironpy throws TypeError: Object is not callable. 

A minimalish test case for both is available at 

Curiously enough, 2.0 alpha5 did not work for me in the actual application 
that am developing - the fact that this test case does gives good hope 
that I can get it working there it too (I thought the case is similar..).

This whole GetInvocationList() seems to be a strange beast, it is only 
available in the same class where the event is defined - not to others 
even if whe event is public, nor even in subclasses (yes, not even in 
c#-written subclasses - that's why my first test case that featured a 
WinForm with buttons etc could not be completed (I could not subclass a 
Button that'd have such a method for clearing event callbacks).

The idea in the app that am developing is that user written scripts can 
register event handlers freely, so when clearing them to add new versions 
of the functions there, I don't have references to the funcs that the old 
version of the script had added. Am now using a workaround where the whole 
instance that has the handlers is re-initialized upon such a restart, but 
would like to have the initial plan of just redefining event handlers on 
the fly work too. So hopefully that'll smooth on 2.0.


More information about the Ironpython-users mailing list