Manual check for updates with ClickOnce

You may also like...

43 Responses

  1. It’s amazing to see how many people can find this blog entry via Google but don’t provide any comments or anything! :)

  2. Antonio says:

    Hi,
    This post is really interesting. I’m researching on clickOnce to see if we can using in my job. Everything looks great, but I have a problem. For some policies of the company, I need to change the installation path. I can’t have clickOnce to install my apps per user in the cache folder. In my research I found that this is not possible. So I wonder if I can make a classic msi installer to setup the app for the first time (and have it installed where I want), but still using clickOnce for checking updates using your code example.
    How can I make the app to ‘think’ that has been deploy using ClickOnce, so the NotDeployedViaClickOnce status says so?
    Is this possible?

  3. Douglas Ross says:

    Hi,

    Thanks for the article, it is exactly what I am looking for….. Unfortunately, I am not that good a coder, and do not understand exactly where to make these changes.

    I also cannot find where MS Studio makes the wizard changes (other than in properties).

    I thought that if I found the default stuff set up by the wizard then I should be able to overwrite it with the delegations you have written above.

    Would you be able to post an example forms C# project, that shows exactly where you place this code.

    Apologies in advance, if I am being terribly simple and the answer is obvious.

    Douglas

  4. Hi Douglas,

    I’m giving a training today. If I find the time between practices or so, I’ll create and upload a solution.

  5. Seems like I did it faster than I expected. I added the example for VS2005 without the BackgroundWorker.

    The link is just below the article, as UPDATE 2.

    If you want one with the BackgroundWorker included, or anything else, let me know.

  6. nicolas says:

    Hi,

    How can I manually specify the update location.
    The application will be installed in multiple clients where internet is not available. So I need the administrator of each of our clients to manually copy the files to a specific location so that all clients can be updated.

  7. Rob Kent says:

    The main issues I have with ClickOnce are the install directory and config overwrites. Let’s assume I want my users to be able to manually update the app.config – firstly, how do they know where it is? Secondly, what happens on next update and I have made changes to the central copy – this would overwrite the customer’s changes.

    I’ve looked at lots of ClickOnce articles and have still not seen a satisfactory solution to this problem.

  8. Constandinos Iezekiel says:

    Very helpful article Dennis. It helped a lot :)

  9. Muttly says:

    Hi,

    It’s an interesting article Dennis.

    Without sounding like a complete retard (I have my moments!), what files do we need to put where to set up updates?

    Thanks in advance for your help!

    Muttly

  10. Dennis van der Stelt says:

    I am preparing a post about doing builds with FinalBuilder, explaining also the entire process that needs to be done if you’d do this by hand.

    Hold on for it, I’ll finish it any time soon.

  11. Geir Brandt says:

    Hi,

    thanks for a thorough and excellent explanation. It was exactly what I hoped Google would help me with :)

  12. Edgar Rodriguez says:

    This is a pretty interesting blog post. I just have one quick question, how do I specify in the publish stage in Visual Studio if a update is required?, I mean, where does the info.IsUpdateRequired variable is set? Do I have to modify the deployment manifest manually?

    Thanks,
    Greetings.

  13. Dennis van der Stelt says:

    “Publish” tab in project’s properties window

  14. Rich says:

    A few questions.

    1. Does the background worker check for updates with out a user physically pressing a button?

    2. With this code:

    ApplicationDeployment updateCheck = ApplicationDeployment.CurrentDeployment;

    UpdateCheckInfo info = updateCheck.CheckForDetailedUpdate();

    //

    if (info.UpdateAvailable)

    {

    updateCheck.Update();

    MessageBox.Show(“The application has been upgraded, and will now restart.”);

    Application.Restart();

    }

    Can I place this on form Load?

  15. Dennis van der Stelt says:

    @Rich : 1. Yes, it can 2. Yes, you can.

    It’s probably wiser though to put the checking in parallel process with a BackgroundWorker for example.

    I did bump into one single Windows Forms application where this wasn’t wise, as it took 1 minute to load a LOT of data. After the 1 minute loading, it said “Hey, update, wanna install and restart the app?” and users of the app wouldn’t update because they had to wait another full minute. So checking for updates before the actual loading of the data took place was smarter! :)

    Of course a complete redesign of the app was even more smarter, but there’s not always time for that.

  16. Rich says:

    Just wanted to reply, I did some other stuff, but by following your procedure I was able to help myself implement an update checker.

    I will try to figure out how to use the background checker in a future update ;).

    Thank you for posting this it has helped me.

  17. Dennis van der Stelt says:

    @Rich : No problem, good luck!

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

    How can i implement this solution in a class????

  19. Dennis van der Stelt says:

    @Felipe : What do you mean by that?

  20. BP says:

    Hi Dennis,

    This is really great stuff. Thanks for writing it up.

    I’m using Visual Studio 2010, could you tell me where to inject the deployment code? I have a WPF project and would like to turn off the automatic check for updates too, or at least control its behavior more.

  21. BP says:

    Nevermind, I ignore my last questions… I figured it out. Thank you for the article!

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

    It is possible, for example, if I have a BackgroundWorker in different forms in my application, that change in the role of main window. My question is: Can i put the code in the DoWork and RunWorkerCompleted events in a class and just call in the events, and how i can do it?. Thanks for all.

  23. Dennis van der Stelt says:

    @Felipe : Those questions aren’t ClickOnce related at all. You can put anything inside classes you want and have background workers there, or have backgroundworkers in your form execute the methods in your other class. There are a million possibilities there.

  24. Domnica says:

    Hi,

    I have some files needed for the application to run (dll-s that I cannot add as references because they are not .NET-style, other config files, etc, so they are not deployed by ClickOnce technology), so after publishing the app, I will copy by hand these files to the server, and when app starts I want to copy them dinamically from server to client local disk. (if this is the very first time the app is running on that machine and these files don’t already exist on local disk). They will not modify from one version to another, so I won’t copy them to server every time.

    To copy these files from server to client, of course I have to know server (deployment) location and client location (directory where the app starts on local disk).
    For server location I tried to use ApplicationDeployment.CurrentDeployment.UpdateLocation, but it gave me http://193.33.94.254/MyApp/ MyApp.application (the content of deploymentProvider tag), so not the place where I can find
    For client location I tried to use ApplicationDeployment.CurrentDeployment.DataDirectory, but again this is not the directory from the local disk where the .exe locates.
    So I guess for client side I could use the old System.Windows.Forms.Application.StartupPath, right?

    But what can I do about server location? How to obtain http://193.33.94.254/MyApp/ Application%20Files/ MyApp_1_0_0_7/ let’s say?

    Thanks,
    Domnica

  25. Patrick McGowan says:

    Hello Denis,

    Did you answer Antonio’s comment as I have the same issue and am unable to solve this. Can you help:-

    **********************
    Antonio said:
    Hi,

    This post is really interesting. I’m researching on clickOnce to see if we can using in my job. Everything looks great, but I have a problem. For some policies of the company, I need to change the installation path. I can’t have clickOnce to install my apps per user in the cache folder. In my research I found that this is not possible. So I wonder if I can make a classic msi installer to setup the app for the first time (and have it installed where I want), but still using clickOnce for checking updates using your code example.

    How can I make the app to ‘think’ that has been deploy using ClickOnce, so the NotDeployedViaClickOnce status says so?

    Is this possible?
    *****************

    Regards: Patrick

  26. RudolfGutlich says:

    Hi, I´ve stopped by your site and I am trying to use your tips. I am now stuck with two problems:

    1 – I´ve disabled the autoupdate and did the check programatically.
    When I install the application and there is no new version on the site, there is no warning (ok).
    If there is a new one, then a dialog is shown and if if I select OK, the app updates itself.
    But, if I bypass the update option and quit the app, next time I run it then the “AutoUpdate” window of ClickOnce appears, showing the “OK” and “Ignore” buttons. Why is this happening? I double checked the Publish settings… :(

    2 – I have a version 1.0.0.96 in my web site, and I generate the .97 but I didn´t published it to web, only installed directly.
    So, I have .97 installed in my computer and .96 in the site. But, when I start the app, it shows me that a newer version is on the site and, if I click OK to upgrade, then the .96 version replaces the .97 in my computer.
    How can I stop this bizarre behavior? It is a bug? It is also happening in other application that uses the AutoUpdate from ClickOnce.

    Well, besides that, very Thank You for your great site!

    Best Regards,

    Rudolf Gutlich.

  27. Carel says:

    Excellent! This solved a caching issue too for me!

  28. Shah says:

    Hi,

    I was wondering how ClickOnce detects that an application update is available. Does it look only at the application’s version number ? Lately, I changed my application clickonce deployment so that it is deployed in x86 mode instead of the MSIL mode. After doing this, clickonce was NOT updating my previously installed but it was installing a new copy of my application as if my application was being newly installed.

    Could anyone shed some light on how and when ClickOnce determines that it should update an application ? Whether changing parameters such as the application installation URL, Processor architecture and so on, make clickonce believe troubles Clickonce and make it consider the application being deployed as a brand new application ?

    Regards

  29. Dennis van der Stelt says:

    @Shah : Thanks a lot for replying with the link! Probably helps others as well!

  30. Nice. I was looking for a simple, manual way to check for updates, and lo and behold, I found a fantastic family of routines to do it and do it well.

    Thanks for sharing. :)

  31. StevieC says:

    Just deployed my first two ClickOnce apps, before i read this post!! Now need to change them and redeploy them!! Wish i’d found this post first!! Great Post and expertly explained!!

    Thanks

  32. Art Colman says:

    Dennis,

    I’m wondering if you have any comments, suggestions, or opinions about how to use ClickOnce in an IE9 environment? I found the SmartFilter indication that a clickonce setup.exe is not typically run as very strong and would probably motivate a user not to try the program.

    Cheers,

    Art
    http://www.drybridge.com

  33. Dennis van der Stelt says:

    @Art : The .application file/link is the one you want. It should run with no problems from any IE version. Firefox needs a small update.

  34. Machado says:

    Good job and good article

  35. Peter Durst says:

    Very Nice Tutorial.

    Thank you for sharing!
    Greetz Peter

  36. Remember to user checkForDetailedUpdate(false), or the nasty Win3.1 style dialog box will keep on showing…

  37. Rajesh says:

    Please provide a solution :
    I want to delete existing SQLCE version at client PC during Clickone installation programatically

  38. Smilwe says:

    Is it possible to programatically set update source location?

  39. Smiler says:

    Is it possible to programatically set update source location?

  40. Dennis van der Stelt says:

    @Smiler: Nope

  41. I have a problem with the manually update, when I unchecked the automatic checking for updates. In the next update my antivirus kaspersky Internet security 2012 detected like a virus. I don’t why does it happen?? do you have any ideas?

    The antivirus message:
    Detected: PDM.Worm.P2P.generic 01/10/2012 04:22:11 p.m.

    PD.
    I signined the clickonce manifests.
    If I check the automatic checking for updates. the antivirus doesn’t blocked my application.

  42. anand says:

    Hi.. I am also using Clickonce at work. I need to do manual checking for updates,and if the update is available need to update the application also. But I have a big problem,everything seems to be working fine. But the application never gets updated.Looks like Update() Method is not working.What could be causing so??..Any help would be appreciated..

Click on a tab to select how you'd like to leave your comment

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>