Click here to Skip to main content
15,746,201 members
Articles / Web Development / IIS
Posted 12 Apr 2005


109 bookmarked

Using Updater Block

Rate me:
Please Sign up or sign in to vote.
4.56/5 (36 votes)
12 Apr 20057 min read
A vanilla implementaion showing how Updater Block 2.0 can be included in a Windows Forms application.


I had been trying to include updater block in my application. The quick starts that came along with the application block had some real neat examples, but it took quite some time to figure out what files must be placed where, what settings needed to be made and how, to get a sample of my own working. So, I thought I would post the sample implementation that I generated, along with a step by step guide so that others who will be trying this point onwards need not struggle much.

Note: A good tutorial for updater block version 1.0 can be found here.

The example below tries to show the usage for the version 2.0 of the Updater block.


  • The Enterprise library and the Updater application block must be downloaded and installed. The enterprise library can be downloaded from here.
  • The updater block can be downloaded from here.

System Requirements

  • Supported Operating Systems: Windows XP.
  • Windows XP Professional.
  • Internet Information Server version 5.0 or later.
  • Microsoft .NET FrameWork version 1.1 SDK.
  • Microsoft Visual Studio 2003.
  • Background Intelligent Transfer Service (BITS) (for the out-of-the-box downloader to function correctly).


  1. Create a simple Windows form application .
    • Open VS .NET editor and select File -> New Project -> Windows Application.
    • Change the name to SampleApplication.
    • Change the name of the default form generated to SampleForm.cs
    • Add a label on the form SampleForm and set its text to “Version”
    • Add a button to the form and change its text to “Exit”. Add the event handler to exit the application - Application.Exit();.
    • Add a listbox called eventList.
    • Open the AssemblyInfo.cs and change the version of the application to [assembly: AssemblyVersion("")]
    • Change the line in Main () body to Application.Run(new SampleForm());.
    • Add app.config to the application: Add -> New Item -> Application Configuration File.
    • Build the application.
  2. Add the updater application block to the application.
    • The three assemblies that have to be referenced are present under the folder C:\Program Files\Microsoft Patterns & Practices\Updater Application Block 2.0\src\cs (if the default settings were chosen during the installation of the updater block).
    • The three DLLs can be found in the bin/debug folders of the ActivationProcessors, Downloaders and Updater projects present under the common folder mentioned above.
    • Add refernce to the three DLLs to the created sample application:
      1. Microsoft.ApplicationBlocks.Updater.ActivationProcessors.dll
      2. Microsoft.ApplicationBlocks.Updater.Downloaders.dll
      3. Microsoft.ApplicationBlocks.Updater.dll
    • Add the code, present at the end of the document to the application that forms the body for handling the download (from the #region Auto-Update Stuff To #endregion).

      Note: The downloadable source has this content, but what the heck.

    • Add the following code to the constructor of the SampleForm Class to start off the updater manager:
      InitializeAutoUpdater ();
  3. Update the App.Config file using Enterprise library Configuration Tool.
    • Open the tool from Start -> All Programs -> Microsoft Patterns and Practices -> Updater Application Block V2 -> Enterprise Library Configuration Tool.
    • In the Configuration tool console, select File -> Open Application and browse to the App.Config file, select and click Open.
    • A new item “Application” appears under the root “Enterprise Library Configuration”.
    • Rightclick Application and select New –> Updater Application Block Configuration.
    • Configuration, Cryptography and Updater Application Blocks are added.
    • Update the properties of the application block:
      1. ApplicationID: SampleApplication.
      2. BasePath: C:\Temp\UpdaterTest\UAB.
      3. ManifestUri: http://localhost/ApplicationBlockServer/ServerManifest.xml.

        Note: The ManifestUri will point to a URL that has to be created later.

    • Rightclick Updater Application Block and select New -> Downloaders.
    • Rightclick Downloaders and select New -> BITSDownloader.
    • Save.
  4. Deploy the Client
    • Build the SampleApplication project.
    • Copy the output of the project from the bin/Debug folder to the folder C:\Temp\UpdaterTest. The files to be copied are:
      1. All the DLLs including the following:
        1. Microsoft.ApplicationBlocks.Updater.ActivationProcessors.dll
        2. Microsoft.ApplicationBlocks.Updater.dll
        3. Microsoft.ApplicationBlocks.Updater.Downloaders.dll
      2. The application exe: SampleApplication.exe
      3. The config file: SampleApplication.exe.config
    • Copy the files updaterconfiguration.config and securitycryptographyconfiguration.config present in the root folder of the project to the folder UpdaterTest.
  5. Change the project to create the server application.

    The server application will be a newer version of the application deployed at c:\temp\ UpdaterTest.

    • Open the SampleApplication solution in VS.NET editor.
    • Open SampleForm in designer mode and make noticeable changes on the form. Change the label text to “Version” and the form text to “Sample Form New Version”.
    • Open AssemblyInfo.cs and change the assembly version to [assembly: AssemblyVersion("")].
    • Build the application.
  6. Deploy the Server Application.

    The new version of the application will be deployed at the server, from where it can be downloaded.

    • Create a folder called ApplicationBlockServer under C:\inetpub\wwwroot.
    • Open IIS manager (Start -> Run -> Inetmgr).
    • In the IIS manager, navigate to Default Web Site.
    • Rightclick on Default Web Site and select “New -> Virtual Directory”.
    • Create a virtual directory with alias ApplicationBlockServer and the folder pointing to ApplicationBlockServer folder created above.
    • Create a new folder called under the folder c:\inetpub\wwwroot\ ApplicationBlockServer.
    • Copy the file SampleApplication.exe built in the previous step to the newly created folder
  7. Build the Manifest file for the server
    • Open the Manifest Editor tool that was also installed along with the updater block (Start -> All Programs -> Microsoft Patterns and Practices -> Updater Application Block V2 -> Manifest Editor Tool.
    • Under Manifest Properties Tab, click the Generate button and generate the manifest id. Check the Mandatory check box.
    • Enter the description “Sample Application Version”.
    • In the application properties tab, enter the application id as “SampleApplication” and location as “.”
    • The entry point is “SampleApplication.exe”.
    • The File URI is http://localhost/ApplicationBlockServer/
    • The source folder is “C:\Inetpub\wwwroot\ApplicationBlockServer\”.
    • Click the “Add” button and select SampleApplication.exe from the folder. The file must appear in the Files list.
    • In the activation process tab, enter the process name as AppDeploy and processor type as “Application Deploy” and press “Add”.
    • Enter process name as “WFE” and processor type as “Wait For Exit” and press Add. A new window prompts to add a process name. Press Cancel.
    • Click the Validate button to validate the generated manifest.
    • Click the Save button to Save the manifest at “C:\Inetpub\wwwroot\ApplicationBlockServer” as “ServerManifest.xml”.
  8. Run the application at “C:\Temp\UpdaterTest”.

    The application, after some time, will pops up a dialog box telling that a newer version is available and do you want to download it. Click yes. The newer version will be downloaded which will be displayed in the list box eventList. After downloading, it will prompt you to restart the application. Close the application and start it again. The version will open up.


    • Once the update of the application happens, a folder called UAB gets created in the UpdaterTest folder. This folder gives the information about the latest version present.
    • From what I could understand, the manifest ID is maintained at the server and if an update occurs for the client, the manifest ID is placed in the UAB folder. If the manifest ID of the server is different from that of the client (or if the client does not have the UAB folder, meaning no updates have yet taken place), the updater block swings into action.
    • To deploy a newer version of the application on the server, create a new folder and dump all the files at that location (the naming convention is just a convention for convenience, not a rule) and generate a new server manifest file with a new Manifest ID and replace the old manifest file.
    • I have not checked the auto update feature, i.e. the client can be scheduled to ping the server at regular intervals. But this must be straight forward as setting some property somewhere.
    • The code below has a thread to ping the server every 10 seconds. That part can be removed.

Hey, this was just a vanilla implementation.

Auto Update Code to be pasted in the application

#region Auto-Update Stuff
    private Thread pollThread = null;
    private int manifestDownloaded = 0;
    private void CheckAndUpdate()
          // Get the updater manager
          ApplicationUpdaterManager updater = 
          // Subscribe for various events
          updater.DownloadStarted +=
              new DownloadStartedEventHandler(updater_DownloadStarted);
          updater.DownloadProgress += 
              new DownloadProgressEventHandler(updater_DownloadProgress);
          updater.DownloadCompleted += 
              new DownloadCompletedEventHandler(updater_DownloadCompleted);
          updater.DownloadError += 
              new DownloadErrorEventHandler(updater_DownloadError);
          updater.ActivationInitializing += 
              new ActivationInitializingEventHandler(updater_ActivationInitializing);
          updater.ActivationStarted += 
              new ActivationStartedEventHandler(updater_ActivationStarted);
          updater.ActivationInitializationAborted += 
              new ActivationInitializationAbortedEventHandler(
          updater.ActivationError += 
              new ActivationErrorEventHandler(updater_ActivationError);
          updater.ActivationCompleted +=
              new ActivationCompletedEventHandler(updater_ActivationCompleted);
          // Loop till the updates are available
           Manifest[] manifests = null;
              manifests = updater.CheckForUpdates();
              if(manifests.Length > 0)
                 // Prompt user if he wants to apply the updates
                 if( MessageBox.Show(this,
                    "Update for Auto Inproc Application is available,"+
                    " do you want to apply the update?",
                    "Update",MessageBoxButtons.YesNo)== DialogResult.Yes)
                    foreach(Manifest m in manifests)
                       m.Apply = true;
                    // update the application as per manifest details.
                    updater.Download( manifests, TimeSpan.MaxValue );
                    if(manifestDownloaded == manifests.Length)
                       updater.Activate( manifests );
                       manifestDownloaded = 0;
           // Do nothing if the thread is being aborted, 
           //as we are explicitly doing it
        catch(Exception ex)
     private void exitButton_Click(object sender, System.EventArgs e)
     private void updater_DownloadStarted(object sender, 
         DownloadStartedEventArgs e)
        UpdateList("DownloadStarted for manifest: " + e.Manifest.ManifestId);
     private void updater_DownloadProgress(object sender, 
                                       DownloadProgressEventArgs e)
        UpdateList("DownloadProgress for manifest: "+ e.Manifest.ManifestId +
          "- Files: "+e.FilesTransferred+"/"+e.FilesTotal+
          " - Bytes: "+e.BytesTransferred+"/"+e.BytesTotal);
     private void updater_DownloadCompleted(object sender, 
                                   ManifestEventArgs e)
        UpdateList("DownloadCompleted for manifest: " + 
     private void updater_DownloadError(object sender, 
                           ManifestErrorEventArgs e)
        UpdateList("DownloadError for manifest: " + 
                       e.Manifest.ManifestId +"\n"+e.Exception.Message);
     private void updater_ActivationInitializing(object sender, 
                              ManifestEventArgs e)
        UpdateList("ActivationInitializing for manifest: " + 
     private void updater_ActivationStarted(object sender, ManifestEventArgs e)
        UpdateList("ActivationStarted for manifest: " + e.Manifest.ManifestId);
     private void updater_ActivationInitializationAborted(object sender,
                                            ManifestEventArgs e)
        UpdateList("ActivationInitializationAborted for manifest: " + 
           "The Application needs to restart for applying the updates," +
           " please restart the application.",
           "Auto Inproc Updates",MessageBoxButtons.OK,
     private void updater_ActivationError(object sender, 
                                       ManifestErrorEventArgs e)
        UpdateList("ActivationError for manifest: " + e.Manifest.ManifestId +
     private void updater_ActivationCompleted(object sender, 
                             ActivationCompleteEventArgs e)
        UpdateList("ActivationCompleted for manifest: " + e.Manifest.ManifestId);
     private void UpdateList(string displayString)
    private void InitializeAutoUpdater ()
       // Seperate thread is spun to keep polling for updates
       ThreadStart checkUpdateThreadStart = new ThreadStart(CheckAndUpdate);
       pollThread = new Thread(checkUpdateThreadStart);


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

GeneralMultiples manifests Pin
nerson11-May-05 4:04
sussnerson11-May-05 4:04 
GeneralRe: Multiples manifests Pin
kcjeffery11-May-05 6:31
kcjeffery11-May-05 6:31 
GeneralThread.abort Pin
kcjeffery6-May-05 13:46
kcjeffery6-May-05 13:46 
GeneralRe: Thread.abort Pin
Anonymous16-May-05 7:16
Anonymous16-May-05 7:16 
GeneralContinue tutorial... :) Pin
JFDelges1-May-05 22:19
JFDelges1-May-05 22:19 
Questiondos window?!? Pin
Beziel29-Apr-05 4:38
Beziel29-Apr-05 4:38 
AnswerRe: dos window?!? Pin
ChrisMcConnell5-May-05 1:57
ChrisMcConnell5-May-05 1:57 
AnswerRe: dos window?!? Pin
TLdraw22-Jun-05 4:29
TLdraw22-Jun-05 4:29 
The original quickstart program from microsoft has the namespace Microsoft.ApplicationBlocks.Updater.ActivationProcessors with a class
called WaitForApplicationExitProcessor. You can rebuild this dll with
these changes to get a hidden or minimized console.


//Spawn the wait process
ProcessStartInfo psi = new ProcessStartInfo( "wait.bat" );

before process start add either of these lines:

psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; or
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;

Thomas Ward
Generalmanifest download error Pin
Jorge Da Silva28-Apr-05 2:28
Jorge Da Silva28-Apr-05 2:28 
GeneralRe: manifest download error Pin
kcjeffery6-May-05 13:44
kcjeffery6-May-05 13:44 
GeneralThanks Pin
Ashaman21-Apr-05 7:57
Ashaman21-Apr-05 7:57 
GeneralRe: Thanks Pin
Matt Cantillon22-Apr-05 13:21
Matt Cantillon22-Apr-05 13:21 
GeneralRe: Thanks Pin
Kevin Gray15-Aug-05 1:57
Kevin Gray15-Aug-05 1:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.