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

  • Thread starter Vijayakrishna Pondala
  • 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.
 
V

Vijayakrishna Pondala

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top