ClickOnce manual updates

I’ve written some tutorials in the past to help people with manually updating their ClickOnce deployed applications.

  1. Manual check for updates with ClickOnce
  2. Turn off automatic updates with ClickOnce
  3. ClickOnce automated build and pfx file
  4. Creating ClickOnce deployment files using an automated build and FinalBuilder

clickonce_autoupdate_3[1]

Miscellaneous users still had problems with the updates not checking very well. Joe responded with a solution. I’m writing it down here so more people might benefit from it as well, especially since the comment didn’t contain any linebreaks! 🙂

As Joe mentions the methods CheckForUpdate() and CheckForDetailedUpdate() persist the information retrieved to disk. This way when performing the check for update again, the information is retrieved from disk. If you’ve chosen to skip the update, it won’t ask you again.

You can override this behavior by using an overloaded method of the above mentioned methods and specify that you don’t want the information to be persisted to disk.

ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;
UpdateCheckInfo info = updateCheck.CheckForDetailedUpdate(false);

//
if (info.UpdateAvailable)
{
    updateCheck.Update();
    MessageBox.Show("The application has been upgraded, and will now restart.");
    Application.Restart();
}

Check the second line with the method CheckForDetailedUpdate where I pass a ‘false’ to specify that it should not persist the update information.

You may also like...

5 Responses

  1. Felipe de Jesús Meléndez Valencia says:

    Applied to your last example, where i need to put these code????

  2. Dennis van der Stelt says:

    @Felipe : Anywhere you want! You can do it

    – when the application starts up in Program.cs
    – when the application was launched in your form_loaded or something
    – when the application was launched in your form_loaded, executing it via a backgroundworker
    – behind a button that says “Check for updates”

    Doesn’t really matter.

    Check the other links in the top of this article to find more info! 🙂

  3. Felipe says:

    Thanks. Sorry but i’m new in C#. Thanks for all. You made a great job and a great tutorials.

  4. nike air max says:

    It is my pleasure to read your article, your article is very wonderful. Thank you for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *