本文整理匯總了C#中System.Deployment.Application.ApplicationDeployment.CheckForUpdate方法的典型用法代碼示例。如果您正苦於以下問題:C# ApplicationDeployment.CheckForUpdate方法的具體用法?C# ApplicationDeployment.CheckForUpdate怎麽用?C# ApplicationDeployment.CheckForUpdate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Deployment.Application.ApplicationDeployment
的用法示例。
在下文中一共展示了ApplicationDeployment.CheckForUpdate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InstallUpdateSync
private void InstallUpdateSync()
{
if (ApplicationDeployment.IsNetworkDeployed)
{
Boolean updateAvailable = false;
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
try
{
updateAvailable = ad.CheckForUpdate();
}
catch (DeploymentDownloadException dde)
{
// This exception occurs if a network error or disk error occurs
// when downloading the deployment.
MessageBox.Show("The application cannt check for the existence of a new version at this time. \n\nPlease check your network connection, or try again later. Error: " + dde);
return;
}
catch (InvalidDeploymentException ide)
{
MessageBox.Show("The application cannot check for an update. The ClickOnce deployment is corrupt. Please redeploy the application and try again. Error: " + ide.Message);
return;
}
catch (InvalidOperationException ioe)
{
MessageBox.Show("This application cannot check for an update. This most often happens if the application is already in the process of updating. Error: " + ioe.Message);
return;
}
if (updateAvailable)
{
try
{
ad.Update();
MessageBox.Show("The application has been upgraded, and will now restart.");
Application.Restart();
}
catch (DeploymentDownloadException dde)
{
MessageBox.Show("Cannot install the latest version of the application. Either the deployment server is unavailable, or your network connection is down. \n\nPlease check your network connection, or try again later. Error: " + dde.Message);
}
catch (TrustNotGrantedException tnge)
{
MessageBox.Show("The application cannot be updated. The system did not grant the application the appropriate level of trust. Please contact your system administrator or help desk for further troubleshooting. Error: " + tnge.Message);
}
}
}
}