tags:

views:

2904

answers:

7

I am building a C# windows application. I want it so whenever I click the update button in my form the application will Start looking for whether there is a new version avaliable on my Server.

If there is then proceed to update the Software.

How is this usually handled?

+11  A: 

Take a look at Click Once. This thread might also make an interesting read.

Kurt Schelfthout
ClickOnce has one major drawback - it pops up its own window before starting your own application, which is ugly and confusing to first-time users. It should work like Firefox does, or Reflector...
Krzysztof Koźmic
I read that you can change that behaviour, for example here: http://bloggingabout.net/blogs/dennis/archive/2007/11/05/manual-check-for-updates-with-clickonce.aspx .
Lennaert
@Krzysztof, It doesn't need to do that. It all depends on how you configure and build your update solution. You can write all the clickonce interaction inside your application without the need for the framework-provided dialogs.
J. Steen
A: 

Here are some third party solutions for web deployment:

http://stackoverflow.com/questions/672138/buy-or-build-for-web-deployment

Cannonade
A: 

Here is an Update - Framework provided, but I don't know if it's completed, but perhaps it can help you for your own stuff. If you want to use native technology than I also suggest to use Click Once.

Enyra
A: 

Other answers look great.

However, if you're looking to hand-roll your own for whatever reason, simply put an XML file with information you need for you update process (e.g. description and version number of currently available version) somewhere on a webserver and use a HttpWebRequest (or HttpWebClient?) to download this file and process like you would any XML.

I use this simple method in peSHIr Tweets and it works great. Just update this file when you put new version online for download and your update check will find it. Anything about this process is changeable the way you like, as you wrote it yourself.

Unless this is a private project for your own amusement/use/learning - like in my case - do look if anything already available suits your needs though!

peSHIr
+3  A: 

Let me start by saying we offer a complete updating solution which includes:

wyUpdate handles all of the Vista/Windows 7 UAC problems and all the file permission problems that inevitably pop up when you're trying to update complex software.

That being said, if you want to build your own updater here are some tips:

Building your own updater

A good place to start is the wyUpdate C# source code I mentioned above. You can cannibalize it and use it for your own purposes. Some of the algorithms it contains:

  • Full Windows Vista / Windows 7 UAC support
  • Ability for limited users to check and then update if they have credentials
  • Support for wonky corporate inernet. (If you've ever worked with a corporation this is a real problem).
  • Quick extracting, patching, and installing of files.
  • Registry support.
  • Roll back files & registry on error or cancellation by the user
  • Self-update (no files left behind)

We also have the file specifications here.

Automatic updating

Since being automatic is a requirement let me tell you how we do it with our AutomaticUpdater control.

We use named pipes to communicate between the standalone updater (wyUpdate) and the Automatic Updater control sitting on your program's form. wyUpdate reports progress to the Automatic Updater, and the Automatic Updater can tell wyUpdate to cancel progress, to start downloading, start extracting, etc.

This keeps the updater separate from your application.

In fact, the exact named pipes C# code we use is included in an article I wrote a little while back: Multi-process C# app like Google Chrome.

Wyatt O'Day
I can vouch for wyBuild and wyUpdate being an excellent product. It's much more flexible than ClickOnce, and it's extremely affordable -- one important aspect of software engineering is to know when to buy and when to build, and for me, this was a clear decision to buy.
Mark Rushakoff
+1  A: 

If you want to app update automatically from a website and handle the code by yourself do following steps...

  1. Create an XML file with a unique name for example help.xml and build a structure to specify list of files to be update in specific directories and version and etc the put it on your website...

  2. App after connecting to website download this file and read content to make sure is any new files (update files) exist on website...

  3. If a new version of files was exists so start downloading from url specified in help.xml file!

Jalal Amini
+1  A: 

Hi,

I want to recommend you BitsUpdater. It is simple and extendable library for automatic update process using BITS (technology used by Windows Update).

There is a sample for processes (special project called ApplicationLauncher) and you can extend library with your own solution for updating any other services (database, ...).

jakubgarfield