AutomaticUpdater tutorial for Windows Forms

The AutomaticUpdater control is included with wyBuild and it can be included with your applications royalty free. It works with Visual Studio 2005 through Visual Studio 2019 and .NET 2.0, 3.0, 3.5, 4.x (i.e. 4.0, 4.5, etc.).

This article is about integrating the AutomaticUpdater with Windows Forms apps. We also have articles about integrating with a Windows Presentation Framework (WPF) 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...", then click the "Browse..." button to add the correct AutomaticUpdater.dll.

Adding AutomaticUpdater control to Visual Studio Toolbox

Then simply choose the correct AutomaticUpdater.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 .NET 4.5 apps.

For .NET 2.0, 3.0, and 3.5

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

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

For .NET 4.0 and .NET 4.5

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

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

After you've added the correct AutomaticUpdater.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 form.

Adding AutomaticUpdater control to a form

Finishing touches

Check for update menu

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

Adding menu to your form

Then associate the menu item with the AutomaticUpdater control.

Set the GUID

Also generate a GUID (Globally Unique ID) for the AutomaticUpdater control by clicking the ellipsis button.

AutomaticUpdater properties

Anchor

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

Anchor property

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

Anchor 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();

    // 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()

    ' 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