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.
- 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).
- 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
SampleFormand set its text to “Version 126.96.36.199”
- Add a button to the form and change its text to “Exit”. Add the event handler to exit the application -
- Add a listbox called
- Open the AssemblyInfo.cs and change the version of the application to 188.8.131.52: [assembly: AssemblyVersion("184.108.40.206")]
- Change the line in
Main ()body to
- Add app.config to the application: Add -> New Item -> Application Configuration File.
- Build the application.
- Add the updater application block to the application.
- The three assemblies that have to be referenced are present under the folder C:Program FilesMicrosoft Patterns & PracticesUpdater Application Block 2.0srccs (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:
- 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
SampleFormClass to start off the updater manager:
- 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:
ManifestUri: http://localhost/ApplicationBlockServer/ServerManifest.xml.Note: The
ManifestUriwill point to a URL that has to be created later.
- Rightclick Updater Application Block and select New -> Downloaders.
- Rightclick Downloaders and select New -> BITSDownloader.
- Deploy the Client
- Build the SampleApplication project.
- Copy the output of the project from the bin/Debug folder to the folder C:TempUpdaterTest. The files to be copied are:
- All the DLLs including the following:
- The application exe: SampleApplication.exe
- The config file: SampleApplication.exe.config
- All the DLLs including the following:
- Copy the files updaterconfiguration.config and securitycryptographyconfiguration.config present in the root folder of the project to the folder UpdaterTest.
- 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.
SampleFormin designer mode and make noticeable changes on the form. Change the label text to “Version 220.127.116.11” and the form text to “Sample Form New Version”.
- Open AssemblyInfo.cs and change the assembly version to 18.104.22.168: [assembly: AssemblyVersion("22.214.171.124")].
- Build the application.
- 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:inetpubwwwroot.
- 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 126.96.36.199 under the folder c:inetpubwwwroot ApplicationBlockServer.
- Copy the file SampleApplication.exe built in the previous step to the newly created folder 188.8.131.52.
- 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 184.108.40.206”.
- 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/220.127.116.11.
- The source folder is “C:InetpubwwwrootApplicationBlockServer18.104.22.168”.
- Click the “Add” button and select SampleApplication.exe from the 22.214.171.124 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:InetpubwwwrootApplicationBlockServer” as “ServerManifest.xml”.
- Run the application at “C:TempUpdaterTest”.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 126.96.36.199 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 188.8.131.52 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
// 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
"Update for Auto Inproc Application is available,"+
" do you want to apply the update?",
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
private void exitButton_Click(object sender, System.EventArgs e)
private void updater_DownloadStarted(object sender,
UpdateList("DownloadStarted for manifest: " + e.Manifest.ManifestId);
private void updater_DownloadProgress(object sender,
UpdateList("DownloadProgress for manifest: "+ e.Manifest.ManifestId +
"- Files: "+e.FilesTransferred+"/"+e.FilesTotal+
" - Bytes: "+e.BytesTransferred+"/"+e.BytesTotal);
private void updater_DownloadCompleted(object sender,
UpdateList("DownloadCompleted for manifest: " +
private void updater_DownloadError(object sender,
UpdateList("DownloadError for manifest: " +
private void updater_ActivationInitializing(object sender,
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,
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,
UpdateList("ActivationError for manifest: " + e.Manifest.ManifestId +
private void updater_ActivationCompleted(object sender,
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 may to use can be found here
About the Author
'Application > C#' 카테고리의 다른 글
|시간 간격 구하기 (1)||2008.01.28|
|An Asynchronous Socket Server and Client (0)||2008.01.28|
|Using Updater Block (0)||2008.01.28|
|A simple Multi-Threaded Server Client Instant Messenger Application (1)||2008.01.28|
|MyDownloader: A Multi-thread C# Segmented Download Manager (15)||2008.01.28|
|폼 새창 로드시 포커스 문제? (0)||2008.01.28|