Error calling Application.Restart

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 ?
 

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

Similar Threads

Unwanted reboot 2 17

Top