System.ObjectDisposedException

G

Guest

Hello,

I´ve a problem with a small line of code.
For my Windows Application I designed a form for exporting data into xml
files.

I´m opening the dialog with:

ExportDialog export = new ExportDialog();
export.Show();

and I´m getting the following exception:

System.ObjectDisposedException was unhandled
Message="Cannot access a disposed object.\r\nObject name:
'ExportDialog'."
Source="System.Windows.Forms"
ObjectName="ExportDialog"
StackTrace:
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at [...]



What do I do wrong?

Another form, my import dialog works fine with the same lines of code:


ImportDialog import = new ImportDialog();
import.Show();



Regards,

Martin
 
T

Tom Porterfield

Hello,

I´ve a problem with a small line of code.
For my Windows Application I designed a form for exporting data into xml
files.

I´m opening the dialog with:

ExportDialog export = new ExportDialog();
export.Show();

and I´m getting the following exception:

System.ObjectDisposedException was unhandled
Message="Cannot access a disposed object.\r\nObject name:
'ExportDialog'."
Source="System.Windows.Forms"
ObjectName="ExportDialog"
StackTrace:
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Form.CreateHandle()
at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at [...]

What do I do wrong?

Another form, my import dialog works fine with the same lines of code:

ImportDialog import = new ImportDialog();
import.Show();

Where in your form (what method or event) is the ExportDialog code?
 
?

=?ISO-8859-1?Q?Martin_P=F6pping?=

I just found the error.

Because of a copy&paste mistake I had a this.close() in the
Export class constructor. ;)


Regards,
Martin
 
T

Tom Porterfield

I just found the error.

Because of a copy&paste mistake I had a this.close() in the
Export class constructor. ;)

Regards,
Martin

That would cause that type of problem.
 

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