Unhandled exception after calling child form's Dispose().

  • Thread starter Thread starter Vijayakrishna Pondala
  • Start date Start date
V

Vijayakrishna Pondala

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.
 
Sorry, I forgot to tell, I am getting the unhandled exception when i click
on the File->New Menu item.
 
Back
Top