System.ObjectDisposed Exception when Button is clicked

  • Thread starter Thread starter Treadstone
  • Start date Start date
T

Treadstone

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.
 
Back
Top