Error calling Application.Restart

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I get this exeption when calling Application.Restart

System.InvalidOperationException occurred
Message="Collection was modified; enumeration operation may not execute."
Source="mscorlib"
StackTrace:
at System.Collections.ArrayList.ArrayListEnumeratorSimple.MoveNext()
at System.Windows.Forms.Application.ExitInternal()
at System.Windows.Forms.Application.Restart()
at Presentation.MainForm.CheckForNewVersion() in C:\Documents and
Settings\ttb\My Documents\Visual studio projects\VOIP
Omstillingsbord\Presentation\MainForm.cs:line 612

This is the calling code:

private void CheckForNewVersion()
{
if
(!System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
MessageDialog.Show("Dette program er ikke netværks
installeret.", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
return;
}

if
(!System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CheckForUpdate())
{
MessageDialog.Show("Der er ikke en ny version klar til
download", MessageBoxButtons.OK, MessageBoxDefaultButton.Button1);
return;
}

if (MessageDialog.Show("Der er en ny version klar til download.
Ønsker du at genstarte og få den installeret?", MessageBoxButtons.YesNo,
MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{

System.Deployment.Application.ApplicationDeployment.CurrentDeployment.Update();
Application.Restart();
}


}


Any idears ?
 
Back
Top