Hi, when unregistering an event handler I get an exection: Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import CLR import CLR.System.Windows.Forms as wf f=wf.Form() f <CLR.System.Windows.Forms.Form object at 0x008FE6D0> def h(s,a): print s,a ... f.Click += h f.Click -= h
Unbehandelte Ausnahme: System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt. at Python.Runtime.EventObject.RemoveEventHandler(IntPtr target, IntPtr handler) at Python.Runtime.EventBinding.nb_inplace_subtract(IntPtr ob, IntPtr arg) The same happens when I try to call the event. The demo apps run without any problem; i.e. Python event handlers are called correctly by the CLR. But trying to unregister the event handler in helloform.py: ... WinForms.MessageBox.Show("Please do not press this button again.") self.button.Click -= self.button_Click causes the same exception as shown above. Michael P.S.: I run CLR v1.1 on Win XP
Hi, when unregistering an event handler I get an exection:
Python 2.3.2 (#49, Oct 2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.
import CLR import CLR.System.Windows.Forms as wf f=wf.Form() f <CLR.System.Windows.Forms.Form object at 0x008FE6D0> def h(s,a): print s,a ... f.Click += h f.Click -= h
Ah - what a wonderful, horrible experience its been, learning all about these little nits of the CLR :) This seems to be related to events that are implemented using internalcall magic. The correct 'official' reflection api one is supposed to use to ignore these details is totally broken in both CLR 1.0 & 1.1, and it seems that my workaround needs some more work ;^/ I've added a (currently failing) unit test to make sure it gets looked at. Thanks! Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
participants (2)
-
Brian Lloyd -
Michael.Amrhein@t-online.de