开发者

Online updating a C# program

Greetings,

I'm sorry if this question has been asked already. I've tried using the search function but couldn't find any answer that suited my situation.

I have a real simple C# form application of only 1 file, a exe. I distributed this currently by 4shared where people can download it as pleased.

However, every time I make changes to the program people will have to download the n开发者_运维百科ew version from 4shared.

Now this isn't a ideal situation and I'm a noob when it comes to creating upgrade but the situation I wish is that the program looks at a website / ftp server where I deploy a new version.

I'm looking for a way inside my program to look at the file on that website / ftp server and decide wether there's a new version available. If there is a new version available in the website / ftp server I would like for the program to update itself to the newest version.

Hope you guys can help me out with this and I hope I explained my situation enough !


NetSparkle is a nice alternative to click-once with more deployment options. http://netsparkle.codeplex.com/


Have a look at ClickOnce. It will do this for you.


When I'm developing and publishing such applications, I usually do it the following way:

  1. Develop a .NET Windows Forms application
  2. Develop a tiny ASP.NET application with an ASMX web service.
  3. Publish the ASMX web service to my public web site.
  4. Add a WSDL reference for the web service to my Windows Forms application.
  5. Create a setup (I prefer Unicode NSIS over ClickOnce).

The logic I implement in the SOAP web service is basically a single function:

[WebMethod]
public string CheckUpdateAvailable( string currentVersion )
{
    ...
}

The Windows Forms application calls this method (e.g. from a background thread upon program start), passing its current assembly version as a string to the function.

The WSDL function in turn checks the passed version against the newest setup version (e.g. being stored inside web.config or extracted live from the setup.exe on the server). If a newer version exists, it return a string with the URL to download from; otherwise it returns NULL.

When the caller of the WSDL function gets a non-NULL string, it can show a message to the user, asking whether he wants to download and install the executable and then simply execute the URL (via Process.Start).


WyUpdate is the way to go here. We've been using it for over a year with great results (they have excellent support too).

It actually uses patches to update files so that when a 5MB executable only has a small change, the client only has to download a file in the order of kilobytes.

They supply an automatic update component for either Windows Forms or WPF that looks nice and works great.

You can host the update files on either an FTP server or a normal website without any server-side configuration.

There's plenty more to it, and the best place to start is with their video tutorial of how to set up an update.


Here's an open-source library I wrote to address specific needs we had for WinForms and WPF apps. The general idea is to have the greatest flexibility, at the lowest overhead possible. All you'll have to do is create an update feed and reference the library from your app.

So, integration is super-easy, and the library does pretty much everything for you, including synchronizing operations. It is also highly flexible, and lets you determine what tasks to execute and on what conditions - you set the rules (or use some that are there already). Last by not least is the support for any updates source (web, BitTorrent, etc) and any feed format - whatever is not implemented you can just write for yourself.

Cold updates (requiring an application restart) is also supported, and done automatically unless "hot-swap" is specified for the task.

This all boils down to one DLL, less than 70kb in size.

More details at http://www.code972.com/blog/2010/08/nappupdate-application-auto-update-framework-for-dotnet/

Code is at http://github.com/synhershko/NAppUpdate (Licensed under the Apache 2.0 license)

I plan on extending it more when I'll get some more time, but honestly you should be able to quickly enhance it yourself for whatever it currently doesn't support.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜