K
kuhrty
Hi,
I am creating a multi-winform project. Everything has been working
fine, except after I perform an update to the database and decide to
Exit the winform after the update operation is complete.
I have error handling in my code but not on the dispose method. I call
the dispose method exiting the application using the code below but
results in this error message
"An unhandled exception of type 'System.NullReferenceException'
occurred in system.management.dll
Additional information: Object reference not set to an instance of an
object."
I am may be using the dispose method incorrectly but I can't seem to
locate the issue. Any advice or hints is greatly appreaciated.
private void mnuExit_Click(object sender, System.EventArgs e)
{
if (MessageBox.Show("Are you sure you want to exit?","Exit",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.Dispose();
}
}
protected override void Dispose( bool disposing )
{
if (!bOK)
{
if (MessageBox.Show("You have not updated the current data. Would you
like to before exiting?", "Exit",MessageBoxButtons.YesNo ) ==
DialogResult.Yes)
{
return;
}
}
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Thanks in advance
Mark
I am creating a multi-winform project. Everything has been working
fine, except after I perform an update to the database and decide to
Exit the winform after the update operation is complete.
I have error handling in my code but not on the dispose method. I call
the dispose method exiting the application using the code below but
results in this error message
"An unhandled exception of type 'System.NullReferenceException'
occurred in system.management.dll
Additional information: Object reference not set to an instance of an
object."
I am may be using the dispose method incorrectly but I can't seem to
locate the issue. Any advice or hints is greatly appreaciated.
private void mnuExit_Click(object sender, System.EventArgs e)
{
if (MessageBox.Show("Are you sure you want to exit?","Exit",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.Dispose();
}
}
protected override void Dispose( bool disposing )
{
if (!bOK)
{
if (MessageBox.Show("You have not updated the current data. Would you
like to before exiting?", "Exit",MessageBoxButtons.YesNo ) ==
DialogResult.Yes)
{
return;
}
}
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
Thanks in advance
Mark