Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic updating of C# programs

Tags:

c#

.net

windows

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

  • a Windows Service
  • a user-space Windows Forms application

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.

like image 695
David Pfeffer Avatar asked Oct 04 '10 02:10

David Pfeffer


People also ask

What is automatic updating in computing?

With the Automatic Updates feature, Windows can automatically keep the computer up to date with the latest updates and enhancements. You no longer have to search for critical updates and information; Windows delivers them directly to the computer.

How do I make apps update automatically?

Tap Manage apps & device.Tap Manage, then find the app you want to update automatically. To open the app's "Details" page, tap the app. Turn on Enable auto update.

What is wyBuild?

With wyBuild you generate the patches and use our open source updater, wyUpdate, to update your Windows app. wyBuild & wyUpdate handle all of the details no matter what programming language you use.

How do I fix automatic updates?

First, you go to Settings. Click on Update & Security and then select Windows Update. Click on the Advanced Options and then make sure Automatic is selected under Choose how updates are installed.


2 Answers

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...

like image 132
Preet Sangha Avatar answered Oct 06 '22 23:10

Preet Sangha


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

  • Write Auto-Updating Apps with .NET and the Background Intelligent Transfer Service API
  • .NET Client Applications: .NET Application Updater Component
like image 30
Keith Blows Avatar answered Oct 07 '22 00:10

Keith Blows