Hello,

I have a main form (MainForm) which contains File->New menu item. On
clicking File->New menu item, i am displaying a form (ChildForm) which
contains a lot of controls and a lot of complex code. Everytime the
File->New menu item is clicked, a new instance of ChildForm is created and
shown as modal dialog with MainForm as owner. In the ChildForm's Dispose()
method, i have included code to remove all event handlers, cleanup the
controls etc. After call to ChildForm.ShowDialog(MainForm), i am calling the
ChildForm.Dispose() method explicitly, to release the window handles.

The problem here is I am getting an Unhandled Exception saying
"System.NullReferenceException: Object reference not set to an instance of
an object.
at System.Windows.Forms.ChildWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)".

Please help me!

Thanks,
VijayakrishNa P.

Re: Unhandled exception after calling child form's Dispose(). by Vijayakrishna

Vijayakrishna
Thu Feb 17 04:37:44 CST 2005

Sorry, I forgot to tell, I am getting the unhandled exception when i click
on the File->New Menu item.

"Vijayakrishna Pondala" <pvijkris@hotmail.com> wrote in message
news:OvaUkpNFFHA.2564@tk2msftngp13.phx.gbl...
> Hello,
>
> I have a main form (MainForm) which contains File->New menu item. On
> clicking File->New menu item, i am displaying a form (ChildForm) which
> contains a lot of controls and a lot of complex code. Everytime the
> File->New menu item is clicked, a new instance of ChildForm is created and
> shown as modal dialog with MainForm as owner. In the ChildForm's Dispose()
> method, i have included code to remove all event handlers, cleanup the
> controls etc. After call to ChildForm.ShowDialog(MainForm), i am calling
the
> ChildForm.Dispose() method explicitly, to release the window handles.
>
> The problem here is I am getting an Unhandled Exception saying
> "System.NullReferenceException: Object reference not set to an instance of
> an object.
> at System.Windows.Forms.ChildWindow.Callback(IntPtr hWnd, Int32 msg,
> IntPtr wparam, IntPtr lparam)".
>
> Please help me!
>
> Thanks,
> VijayakrishNa P.
>
>