Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Programmatically restarting a ClickOnce app using System.Application.Deployment namespace
 

Programmatically restarting a ClickOnce app using System.Application.Deployment namespace

We are creating a custom version of ClickOnce using the System.Applicaton.Deployment namesapce forour WinForms app. This begins with a small stub module that quickly downloads via ClickOnce. It, in turn, checks for new versions of the many modules under its control that are plugged into the app as panels. If any of the modules have changed, they are downloaded as well with a custome progress screen. This is done in order to speed up the download process as well as provide additional infor during the download, such as displaying release notes, etc..

The problem is with the first module. It needs to restart prior to finishing its ClickOnce tasks. However, because ClickOnse loads into a different folder, Application.Restart restarts the original version rather than the updated one. As a consequence, developers have a popup telling users THEY must restart the app, which is not user friendly. It would be better to have ClickOnce restart the new controller app, if possible.

So, the question is, can this be done in programmatically in ClickOnce?

Bill2010  Tuesday, July 07, 2009 9:01 PM
Hi Bill,

If you check for the update and install the new version, if any, programmatically and then call the Application.Restart method after the new version has been installed, the new version of the application will be run.

The following MSDN document provides a sample which determines at application load time whether a new update is available; if a required update is available, the code example installs the update asynchronously and then run the new version of the application by calling Application.Restart mehtod:

http://msdn.microsoft.com/en-us/library/system.deployment.application.applicationdeployment.aspx

Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Wednesday, July 08, 2009 3:16 AM
Hi Bill,

If you check for the update and install the new version, if any, programmatically and then call the Application.Restart method after the new version has been installed, the new version of the application will be run.

The following MSDN document provides a sample which determines at application load time whether a new update is available; if a required update is available, the code example installs the update asynchronously and then run the new version of the application by calling Application.Restart mehtod:

http://msdn.microsoft.com/en-us/library/system.deployment.application.applicationdeployment.aspx

Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Wednesday, July 08, 2009 3:16 AM

You can use google to search for other answers

Custom Search

More Threads

• Setup project with automatic prerequisites installation
• Pre-Requisites for ClickOnce in VS2008
• Setup and app.config : how to not overwrite existing config while installing a newer version ?
• Deployment: "Manufacturer" in installation path AND in Publisher info?
• Update application from a different location
• C# Setup Application
• Publishing to a Folder
• Simple Click Once Deployment generates "An error occurred trying to download" file.
• pass data from a webpage
• Making Setup????