By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,903 Members | 1,977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,903 IT Pros & Developers. It's quick & easy.

System.ObjectDisposed Exception when Button is clicked

P: n/a
Hi All,

I am writing an application in C# (.NET CF) to generate a vCard and
transmit it over bluetooth.
To do this, on the menu item of a form, i generate an "On click Menu
Item" event and that will take me to a new form.
In this new form I use the ChooseContactDialog class to obtain a
contact name from the phone book and store it into a text box.
However, I am getting a System.ObjectDisposed Exception when it enters
into the "On Click Search Button".

The code is as follows:

private void button_SearchContacts_Click(object sender, EventArgs e)
{
ChooseContactDialog objContactDialog = new
ChooseContactDialog();
objContactDialog.HideNew = true;
objContactDialog.ShowDialog();
try
{
Contact appContact = objContactDialog.SelectedContact;
textBox_SelectedContact.Text = appContact.FileAs;

//Call the method that generates the vCard and writes
it to a .vcf file
GenerateVCard(appContact);
}
catch (NullReferenceException)
{
MessageBox.Show("No Contacts");
}

}
Here the "object sender" parameter has some value like this:
{Text = '((System.Windows.Forms.Control)(((System.Windows. Forms.Button)
(sender)))).Text' threw an exception of type
'System.ObjectDisposedException'}

I am clueless. Any suggestions?

Regards,
Treadstone.

Oct 19 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Which line specifically threw the exception?

"Treadstone" <u.*******@gmail.comwrote in message
news:11*********************@v29g2000prd.googlegro ups.com...
Hi All,

I am writing an application in C# (.NET CF) to generate a vCard and
transmit it over bluetooth.
To do this, on the menu item of a form, i generate an "On click Menu
Item" event and that will take me to a new form.
In this new form I use the ChooseContactDialog class to obtain a
contact name from the phone book and store it into a text box.
However, I am getting a System.ObjectDisposed Exception when it enters
into the "On Click Search Button".

The code is as follows:

private void button_SearchContacts_Click(object sender, EventArgs e)
{
ChooseContactDialog objContactDialog = new
ChooseContactDialog();
objContactDialog.HideNew = true;
objContactDialog.ShowDialog();
try
{
Contact appContact = objContactDialog.SelectedContact;
textBox_SelectedContact.Text = appContact.FileAs;

//Call the method that generates the vCard and writes
it to a .vcf file
GenerateVCard(appContact);
}
catch (NullReferenceException)
{
MessageBox.Show("No Contacts");
}

}
Here the "object sender" parameter has some value like this:
{Text = '((System.Windows.Forms.Control)(((System.Windows. Forms.Button)
(sender)))).Text' threw an exception of type
'System.ObjectDisposedException'}

I am clueless. Any suggestions?

Regards,
Treadstone.

Oct 30 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.