bright, fresh software
Downloads  |  Buy

AutomaticUpdater tutorial for WPF apps

The AutomaticUpdater control is included with wyBuild and it can be included with your applications royalty free. It works with Visual Studio 2005, 2008, 2010, 2012 and .NET 2.0, 3.0, 3.5, 4.0, and 4.5.

This article is about integrating the AutomaticUpdater with Windows Presentation Framework (WPF) apps. We also have articles about integrating with a Windows Forms app or integrating with a Windows Service or Console app.

First, get wyBuild

You need wyBuild to use the AutomaticUpdater control, so download wyBuild now. You can use it free for 21-days with no restrictions. And if you don't like it you can uninstall it - no hard feelings & no files laying around.

Then, work yourself through steps 1-3 of the step-by-step walkthrough. This will teach you how to make update patches. Once you've read the walkthrough you're ready to add the AutomaticUpdater to your app:

Add the AutomaticUpdater control to Visual Studio Toolbox

You need to add the AutomaticUpdater control to your Visual Studio Toolbox. Do this by right clicking the Toolbox, selecting "Choose Items...", clicking "WPF Components" tab, then click the "Browse..." button to add the correct AutomaticUpdaterWPF.dll.

Adding AutomaticUpdater control to Visual Studio Toolbox

Then simply choose the correct AutomaticUpdaterWPF.dll for your app. There are 2 separate builds of the AutomaticUpdater: one for .NET 2.0, 3.0, and 3.5 apps and one for .NET 4.0 and 4.5 apps.

For .NET 3.0, and 3.5

If your app is compiled for .NET 2.0, 3.0, or 3.5 then use AutomaticUpdaterWPF.dll located in the "AutomaticUpdater" folder:

C:\Program Files\wyBuild\AutomaticUpdater\AutomaticUpdaterWPF.dll
	or
C:\Program Files (x86)\wyBuild\AutomaticUpdater\AutomaticUpdaterWPF.dll

For .NET 4.0 and .NET 4.5

If your app is compiled for .NET 4.0 or .NET 4.5 then use AutomaticUpdaterWPF.dll located in the "AutomaticUpdater\Microsoft .NET 4.0" folder:

C:\Program Files\wyBuild\AutomaticUpdater\Microsoft .NET 4.0\AutomaticUpdaterWPF.dll
	or
C:\Program Files (x86)\wyBuild\AutomaticUpdater\Microsoft .NET 4.0\AutomaticUpdaterWPF.dll

After you've added the correct AutomaticUpdaterWPF.dll, make sure "AutomaticUpdater" is checked in the list, then click "OK" and the AutomaticUpdater will appear in your toolbox.

Drag the AutomaticUpdater control to your .NET app

Now drag the AutomaticUpdater control to your main window.

Adding AutomaticUpdater control to a window

Finishing touches

Check for update menu

Add a "Check for updates" menu to your window:

Adding menu to your window

Then associate the menu item with the AutomaticUpdater control. You can do this in your Window's constructor by:

C#:
public Window1()
{
    InitializeComponent();

    // set the check for updates menu
    automaticUpdater2.MenuItem = mnuCheckForUpdates;
}
VB.NET:
Public Sub New()
    InitializeComponent()

    ' set the check for updates menu
    automaticUpdater2.MenuItem = mnuCheckForUpdates
End Sub

Set the GUID

You'll need to set a the GUID property of the AutomaticUpdater control. For instance "YourCompany-YourAppName" will be fine.

AutomaticUpdater properties

HorizontalAlignment

Lastly, you can change the way the AutomaticUpdater control animates to show more information by setting the HorizontalAlignment property on the control:

HorizontalAlignment property

If you set the HorizontalAlignment property to "Left" the AutomaticUpdater control will animate rightwards, and if you set the Anchor property to "Right" the control will animate leftwards:

HorizontalAlignment example

Useful Properties & Events

The AutomaticUpdater has quite a few useful events and properties. In particular, the "ClosingForInstall" property and the "ClosingAborted" event are especially useful.

The AutomaticUpdater install updates on 2 conditions. Either the user specifically click "Install updates now" or your application starts and there are updates ready to be installed. In this 2nd case the AutomaticUpdater control sets its "ClosingForInstall" property to "true".

Here's an example of using the "ClosingForInstall" property in the Form's constructor:

C#:
public Form1()
{
    InitializeComponent();

    // set the check for updates menu
    automaticUpdater2.MenuItem = mnuCheckForUpdates;

    // only load files, etc. when NOT closing to install an update
    if (!automaticUpdater.ClosingForInstall)
    {
        // load important files, etc.
        // LoadFilesEtc();
    }
}
VB.NET:
Public Sub New()
    InitializeComponent()

    ' set the check for updates menu
    automaticUpdater2.MenuItem = mnuCheckForUpdates

    ' only load files, etc. when NOT closing to install an update
    If Not automaticUpdater.ClosingForInstall Then
        ' load important files, etc.
        ' LoadFilesEtc()
    End If
End Sub

However, if the update isn't ready to install (because it was corrupted, deleted, or otherwise), the closing of your application will be aborted and the "ClosingAborted" event will be called. You can use this event to load files that you previously skipped in the constructor:

C#:
private void automaticUpdater_ClosingAborted(object sender, EventArgs e)
{
    // your app was preparing to close
    // however the update wasn't ready so your app is going to show itself
    // LoadFilesEtc();
}
VB.NET:
Private Sub automaticUpdater_ClosingAborted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles automaticUpdater.ClosingAborted
    ' your app was preparing to close
    ' however the update wasn't ready so your app is going to show itself
    ' LoadFilesEtc()
End Sub