Publish windows app in C#.net

private void UpdateApp()
{
//log.Debug(“Entering into Update Method”);
UpdateCheckInfo info = null;

if (ApplicationDeployment.IsNetworkDeployed == true)
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

//log.Debug(“Application Deployment is executed”);
try
{
//log.Debug(“Check For Update”);

info = ad.CheckForDetailedUpdate();

//log.Debug(“Check info Completed”);
//   log.Debug(“Check For Update Completed”);
}
catch (DeploymentDownloadException dde)
{
//log.Error(dde);
MessageBox.Show(“The new version of the application cannot be downloaded at this time”);
//    + “. \n\nPlease check your network connection”);
return;
}
catch (InvalidDeploymentException ide)
{
//log.Error(ide);
MessageBox.Show(“Cannot check for a new version of the application.”);
return;
}
catch (InvalidOperationException ioe)
{
//log.Error(ioe);
MessageBox.Show(“This application cannot be updated. It is likely not a ClickOnce application”);
return;
}

//Check Patch Update for DB is available or not

Boolean doUpdate = true;
if (info.UpdateAvailable)
{
//log.Debug(“Check For Update available Yes” + info.AvailableVersion.Build.ToString());

System.Windows.Forms.DialogResult dr1 = System.Windows.Forms.MessageBox.Show(“An update is available. Would you like to update the application now?”, “Update Available”, System.Windows.Forms.MessageBoxButtons.OKCancel);
if (!(System.Windows.Forms.DialogResult.OK == dr1))
{
doUpdate = false;
}
else
{
if (info.UpdateAvailable)
{
try
{

ad.Update();
System.Windows.Forms.Application.Restart();

}
catch (DeploymentDownloadException dde)
{
//log.Error(“Error:” + dde.Message);
return;
}
}
else
{
// MessageBox.Show(“No Application Updates are available…”);
}
}
}
else
{
System.Windows.Forms.MessageBox.Show(“No Application Updates are available…”);
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s