David Pfeffer
David Pfeffer

Reputation: 39823

Automatic updating of C# programs

I'm writing a suite of programs for client PCs --

I need to be able to publish an updated version of these programs and have the client PCs automatically and transparently (with no user interaction) update themselves. This update will be done over an unreliable 3G connection (EvDO). The applications will be continuously running, so the update will have to gracefully shutdown the service / close the applications, and then spin them up again after the update.

Before I spend time rolling my own solution, are there any pre-existing solutions for something similar?

Note: ClickOnce doesn't work here because of the Windows Service as well as several other reasons. I also can't take advantage of BITS because I'm running against Windows Azure, which lacks the BITS IIS plugin.

Upvotes: 8

Views: 1777

Answers (2)

Preet Sangha
Preet Sangha

Reputation: 65466

Why not consider shadow copy.

Shadow copying enables assemblies that are used in an application domain to be updated without unloading the application domain. This is particularly useful for applications that must be available continuously, such as ASP.NET sites.

Make the programs very simple shells. Then have them watch (FileWatcher) for updates to folder where they were loaded from (and where updates are delivered). Then dynamically reload the AppDomain.

See here and here for more info.

You can use the properties of the AppDomainSetup class as follows to configure an application domain for shadow copying:

Enable shadow copying by setting the ShadowCopyFiles property to the string value "true". By default, this setting causes all assemblies in the application path to be copied to a download cache before they are loaded. This is the same cache maintained by the common language runtime to store files downloaded...

Upvotes: 9

Keith Blows
Keith Blows

Reputation: 1690

Two best resources I have come across (both use BITS, which capably handles an unreliable connection).

Upvotes: 2

Related Questions