ObjectDisposedException in AniForm.cs


System.ObjectDisposedException: Cannot access a
disposed object named "EnclosureToastNotify".
Object name: "EnclosureToastNotify".
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at Genghis.Windows.Forms.AniForm.RequestClose()
EnclosureToastNotify is a inherited form (inherit from AniForm).
The reason for that exception is the check for
"this.Handle != IntPtr.Null". This test will create the Handle within
the Handle property (stated in the remarks section of the documentation
about that property).
You should get rid of any of these checks in the forms (incl. AniForm)
and use "this.IsHandleCreated" instead to avoid that kind of exceptions.
I attached a version of that AniForm.cs file I had took out of the Genghis project (formerly we used the DLL) to be able to distribute CLR 1.1 binaries with the latest Genghis code fixes, that are for CLR 2.0). In that file I just did the changes required.
Additionally I added fixes to get rid of Cross-Thread exceptions we got in our project: they are marked witha comment "\TR:" you can search for to verify.
The file attached may not base at the very latest code state - so you have to merge somehow.

file attachments