For one of my .NET Compact Framwork applications I needed some self-auto-update functionality, simliar to what Sparkle does on OSX. Unfortunatly, I couldn’t find any libraries that would help me achieve this goal. The only thing I could find was an outdated article in the MSDN library. But that, like many Microsoft examples, presupposed an IIS with ASP.NET on the server side, which I neither had, nor wanted to use.

So I took the weekend and coded a little library, which I call “WmAutoUpdate” (freely available on Github). It can easily be integrated with your .NET Compact Framework app and works with any webserver that is able to serve files on the server side.

Go on over to Github, get the source and check the “example” folder:

Consider the example folder for a simple example of how to use the framework. The application simply consists of a form, which displays the string “old Version”.

  static void Main()
      Updater updater = new Updater("");
      Application.Run(new Form1());

Upon start, the WmAutoUpdate framework kicks in and downloads the XML file “update.xml” from the update server. The update.xml file looks as follows:

  <?xml version="1.0" encoding="utf-8" ?>
    <download name="WmAutoUpdateExample">
      <version maj="3" min="0" bld="0000"/>
      <message>Important Update. My very important release/update note. This will be displayed within the Update

Pretty self-explanatory. Afterwards, the user can choose whether to update now, or skip the update for now. If the former is chosen, the file described in the “link” tag is downloaded and unpacked into a temporary folder (Unpacking is facilitated through the lib). Next, these files are moved from the temporary folder into the application folder, replacing the outdated files (the outdated files are copied into a backup folder, beforehand). If everything goes well, WmAutoUpdate creates a file called “success” within the backup folder. Lastly, the application is restarted (right now this is implemented via a call to CeRunAppAtTime; Unfortunately, the minimum time-frame this function accepts is 11 seconds. Thus, it will take 11 secs for your app to restart). Upon restart WmAutoUpdate checks for the “success” file within the backup folder. If found, the entire backup folder is deleted. If not, all files within the backup folder are copied back into the application folder (rollback).

Both (which simply contains the same application, but with a form saying “new Version” and the Assembly Version set to 3.0.0) and update.xml can be found in the “Server Files” directory within the example folder. Both files need to be put into the according server web directory.

Tags: , , , , , , , ,

7 Responses to “WmAutoUpdate – a .NET Compact Framework auto-update library”

Hi Sebastian

Thanks very much for making WmAutoUpdate available. I’ve incorporated it into my current project and it works very nicely indeed!

I don’t have a lot of experience with Windows programming and in particular events and threading so I’m having a little trouble following the code. I’ve got a problem that I can’t seem to resolve.

If I cause the application to crash half-way through updating it is supposed to recover by copying the backup version back into the main directory. This doesn’t work because the exe file is “locked” by the operating system because it is currently in use. I can verify this is the case because I can’t delete it using Windows Explorer either. The error details are:

System.IO.IOException was unhandled
at System.IO.__Error.WinIOError(Int32 errorCode, String str)
at System.IO.File.Move(String sourceFileName, String destFileName)
at WmAutoUpdate.Updater.assertPreviousUpdate()
at WmAutoUpdate.Updater..ctor(String url)

The error occurs on this line in Updater.assertPreviousUpdate():
File.Move(f, appPath + “\\” + getFilenameFromPath(f));

To be honest I’m amazed that you were able to copy/delete the application exe file while it was running but I can see that the code manages to do this somehow when it updates the application. The problem is that it doesn’t work when rolling back. Do I need to do it in another thread or something?

Thanks again.


Hi. Thanks for the wmautoupdate, it works perfectly except in the case that Mark Evans pointed out.
I am having the same problem. Wondering if you gave an answer for that question or, if not, maybe you have an idea?

I would really appreciate any comments since I am quite stuck with this problem.

Thanks again.

Hi, I’ve found a solution for this problem:

Thanks for the library, it is great!


[…] application and I’m using WmAutoUpdate to deploy new versions to the mobile devices ( ;) . Has anyone used this? It’s cool but I’ve got a […]

Hi there;

You’ ve just saved my day my friend.

Thanks for this amazing library.

I’m try use your lib on my localhost (use denwer)
In Program.cs I change this line
Updater updater = new Updater(“”);

In TransferManager.cs in VS 2008 i have exception
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
wr.KeepAlive = false;
wr.Proxy = null;

using (HttpWebResponse response = (HttpWebResponse)wr.GetResponse())


Unable to connect to the remote server

Maybe do u know, what my problem???

 Feed for this Entry

Something to say?