I know this is old Q., but I will answer anyway. (hope this helps someone):
First , you need to check: Choose when the application should check for updates → After starting the application .
Secondly, add this method to your code:
private Boolean isVersionOK() { UpdateCheckInfo info = null; if (ApplicationDeployment.IsNetworkDeployed) { ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment; try { info = ad.CheckForDetailedUpdate(); } catch (DeploymentDownloadException) { // No network connection return false; } catch (InvalidDeploymentException) { return false; } catch (InvalidOperationException) { return false; } if (info.UpdateAvailable) { try { ad.Update(); Application.Restart(); Environment.Exit(0); } catch (DeploymentDownloadException) { // No network connection } return false; } return true; } else { return false; } }
Finally, you just need to call isVersionOK () at the beginning of your application and in each of several loops, if necessary, to check for updates. it will return TRUE if you are in its latest version, otherwise it will return FALSE and expect the application to automatically restart to a newer version without user intervention . >.
Ahmed widatalla
source share