[Python.NET] System.NullReferenceException

Michael Amrhein Michael.Amrhein at t-online.de
Wed Oct 29 14:04:11 EST 2003

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

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.


P.S.: I run CLR v1.1 on Win XP

More information about the PythonDotNet mailing list