|
Introduction
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.
Prerequisites
- 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).
Steps
- 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 1.0.0.0”
- 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 1.0.0.0: [assembly: AssemblyVersion("1.0.0.0")]
- 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.
- Add the updater application block to the application.
- 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:
ApplicationID: SampleApplication.
BasePath: C:\Temp\UpdaterTest\UAB.
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.
- 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:
- All the DLLs including the following:
- Microsoft.ApplicationBlocks.Updater.ActivationProcessors.dll
- Microsoft.ApplicationBlocks.Updater.dll
- Microsoft.ApplicationBlocks.Updater.Downloaders.dll
- The application exe: SampleApplication.exe
- 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.
- 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 1.0.0.1” and the form text to “Sample Form New Version”.
- Open AssemblyInfo.cs and change the assembly version to 1.0.0.1: [assembly: AssemblyVersion("1.0.0.1")].
- 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:\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 1.0.0.1 under the folder c:\inetpub\wwwroot\ ApplicationBlockServer.
- Copy the file SampleApplication.exe built in the previous step to the newly created folder 1.0.0.1.
- 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 1.0.0.1”.
- 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/1.0.0.1.
- The source folder is “C:\Inetpub\wwwroot\ApplicationBlockServer\1.0.0.1”.
- Click the “Add” button and select SampleApplication.exe from the 1.0.0.1 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”.
- 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 1.0.0.1 will open up.
Addendum:
- 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 1.0.0.2 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()
{
try
{
ApplicationUpdaterManager updater =
ApplicationUpdaterManager.GetUpdater();
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_ActivationInitializationAborted);
updater.ActivationError +=
new ActivationErrorEventHandler(updater_ActivationError);
updater.ActivationCompleted +=
new ActivationCompletedEventHandler(updater_ActivationCompleted);
Manifest[] manifests = null;
while(true)
{
manifests = updater.CheckForUpdates();
if(manifests.Length > 0)
{
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;
}
updater.Download( manifests, TimeSpan.MaxValue );
if(manifestDownloaded == manifests.Length)
{
updater.Activate( manifests );
manifestDownloaded = 0;
}
break;
}
else
{
Thread.Sleep(10000);
}
}
else
{
Thread.Sleep(10000);
}
}
}
catch(ThreadAbortException)
{
}
catch(Exception ex)
{
MessageBox.Show(this,ex.Message,"Error",
MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void exitButton_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
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: " +
e.Manifest.ManifestId);
manifestDownloaded++;
}
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: " +
e.Manifest.ManifestId);
}
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: " +
e.Manifest.ManifestId);
MessageBox.Show(this,
"The Application needs to restart for applying the updates," +
" please restart the application.",
"Auto Inproc Updates",MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
private void updater_ActivationError(object sender,
ManifestErrorEventArgs e)
{
UpdateList("ActivationError for manifest: " + e.Manifest.ManifestId +
"\n"+e.Exception.Message);
}
private void updater_ActivationCompleted(object sender,
ActivationCompleteEventArgs e)
{
UpdateList("ActivationCompleted for manifest: " + e.Manifest.ManifestId);
}
private void UpdateList(string displayString)
{
eventList.Items.Add(displayString);
eventList.Update();
}
private void InitializeAutoUpdater ()
{
ThreadStart checkUpdateThreadStart = new ThreadStart(CheckAndUpdate);
pollThread = new Thread(checkUpdateThreadStart);
pollThread.Start();
}
#endregion
| You must Sign In to use this message board. |
|
| | Msgs 1 to 25 of 88 (Total in Forum: 88) (Refresh) | FirstPrevNext |
|
 |
|
|
 |
|
|
Hi, This artice is awesome. I need a help. When i am runing Client Exe. A message comes that Do you want update after yes. A message added to list Activation Intialization Aborted for monifest and i am not able to see new uodated exe. Can any body tell me that why i am not getting new file?
-Dheeraj
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I faced the same problem earlier. I found that my manifest file was not created properly, I do not tick on the file checkbox the second time and created the manifest file, and it works now.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Hi, This tutorial is awesome, and just what I needed. BUT....
I'm getting the ActivationInitializationAborted for Manifest message in the EventListBox, but the deployed application was updated anyway. Is this normal? If it's not then does anybody have any Idea what is causing this?
Thanks!
U Xux
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
It's Aborted because user need to restart the application for the exe to be replaced. Yay, it's normal. I think you can just replace the message if you want to.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I develop add-in for MS Outlook and want to implement auto update. Use Updater Block 2.0 All works well: find new version, download it. But when initialize WaitForApplicationExitProcessor and run PostApplicationExitActivationProcess.exe there are anhandling error of PostApplicationExitActivationProcess.exe. May be that is because of: add-in - it is one assembly and outlook - it other application. What should I set in app.config and in manifest file in this case, for that - my apdate should wait when Outlook close and run msi (I download msi-file and next process after WaitForApplicationExitProcessor is MsiProcessor)?
Thank for help.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
How to set an http authentification on the ServerManifest.xml ? I have try :
but it doesn't work... Do you have any ideas to access on the ServerManifest.xml even if it need authentification to be read.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 System popup a message When begin download upgrade file, The error descript as below:
"The server did not return the file size." The URL might point to dynamic content.The Content-length header is not available in the server's HTTP reply."
I don't know why occurred this problem, The problem still exist when i try to change server.
Thanks
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
i am trying to your implementaion in visual studio 2005 and that Update the App.Config file using Enterprise library Configuration Tool is not working as you have told the cpdes for visual studio 2003 please do help me in this.
gurrumurthi
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
hi, i would like to know which is the location in the client where the files are downloaded from the server. thanks anup
|
| Sign In·View Thread·PermaLink | 1.50/5 (2 votes) |
|
|
|
 |
|
|
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.
Look deep inside the UAB folder (in your application's folder).
-- modified at 15:16 Friday 17th March, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
Hello,
We tried and used quite gracefully this sample app, and it works fine on our local development machine (France)
However, when switching in remote testing, we place the relevant ServerManifest.xml file and version folder on a US dedicated server.... and then... patatras !
The following exception message is thrown when accepting the update : " The ressource language ID cannot be found in the image file".
Do anybody here have any clue about that ? Is there a particular setting on our US machine we should be aware of ?
Thanks a lot the the clues ?
Marc
MarcusNaderus contact@savstar.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi,
I had the same problem, and it appears that this problem came from the Web server which host the update. I changed the server to Apache and it works fine.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I get the same error message when running on a Danish devopment machine. And using an american server to place the ServerManifest.xml file.
Is there anyway to make the application compatible with different versions (Danish, american, french etc)?
I also need clues
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The Solution for the problem is very simple
In the ManifestFile Configuration (Manifest Editor) in Application Propertie Tab set the Files URI with the remote Server Location, NOT LOCALHOST, because that indicates to the client download update from local machine, and then generate an error in client than handled with ComException
Sorry for my poor English
----------------------------------------------
In Spanish
Saludos..
La solución al problema es bastante simple.
Resulta que en el ejemplo aparece que al momento de crear el archivo Manifest, se debe especificar en la pestaña "Application Propertie" del Manifet Editor, el valor de "Files URI", con "localhost". Esta situación le indica al cliente al momento de descargar el archivo Manifest que las actualizaciones a descargar estan en su propio computador, lo cual es muy dificil, sin embargo puede ocurrir y claro, cuando probamos la actualizacion desde la máquina en la que tenemos la actualización, esto funciona sin ningun problema.
La solución entonces, es que en vez de poner "localhost" pongan la dirección del servidor desde donde estaran contenidas las actualizaciones.
Ojala les sirva esta solución... al menos a mi me salvo.
Exito en todo
Roberto González Chile
-- modified at 1:34 Friday 15th December, 2006
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hello,
We tried and used quite gracefully this sample app, and it works fine on our local development machine (France)
However, when switching in remote testing, we place the relevant ServerManifest.xml file and version folder on a US dedicated server.... and then... patatras !
The following exception message is thrown when accepting the update : " The ressource language ID cannot be found in the image file".
Do anybody here have any clue about that ? Is there a particular setting on our US machine we should be aware of ?
Thanks a lot the the clues ?
Marc
MarcusNaderus contact@savstar.com
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hello
I have the same problem. Are you find a solution for this problem.
I need help with this problem, if you have any information about it, please send me (rgonzal@netexpress.cl)
Thank you
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
The sample form just sits. No messages, nothing.
I'm wondering if this is the piece that is missing? and where would I get it. - Background Intelligent Transfer Service (BITS) (for the out-of-the-box downloader to function correctly).
I've gone through the sample steps and I'm not sure where to begin debugging. It seems a bit complicated. Can anyone describe how the various pieces interact with each other? The thread uses ApplicationUpdaterManager to check for manifests that require updating. How does it find the manifest file?
manifests = updater.CheckForUpdates();
Thanks,
Gerry
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Just wondering if the new .NET ApplicationDeployment Class (described at http://msdn2.microsoft.com/en-us/library/system.deployment.application.applicationdeployment.aspx) would be a substitute for this arch?
-bac
Bob C.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 I've tried, but found that even I put the ManifestEditor.exe within the same directory with the application exe, then generate the manifest file with file hash (also follow the instruction to click "use hash" optionbox).
But every time the application updater always download the same file from the server, even they files between the client & server are same!
I don't know why, what is wrong ? Is there anything I missed ?
Could you help me ? Thanks!
Do or do not, there is no try.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
Just checked the manifest tool editor source code. I noticed this one DO NOT use SALT for hashing whatever the "saltEnabled" value set in the "securitycryptographyconfiguration.config" !
Therefore you must set saltEnabled to 'false' in the "securitycryptographyconfiguration.config" or when using the Enterprise Library Configuration to generate this file.
Just tried, and now partial update works fine !
The AutoInproc quickstart sample has the bug...
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
Well friend... I have been workinf with All the Application blocks including Updater Application Block (with a hard way)
The problem i have is with the 2 diferent applications (console) to set the parameters in the app.config file. They work well independent but if you create first the app.config with Enterprise Library Configuration Tools(console for updater) after you can not acces the app.config with Enterprise console to set the rest of the configuration because a mistake is sent...
I know a the problem is because Enterprise Library doesnt know(or support) BitsDownloaders but i dont know how to solve this problem -------------------------------------------------------------------------- System.IO.FileNotFoundException: File or assembly name Microsoft.ApplicationBlocks.Updater.Downloaders, or one of its dependencies, was not found. File name: "Microsoft.ApplicationBlocks.Updater.Downloaders" at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationSettingsLoader.GetTypes(XPathNavigator navigator) ----------------------------------------------------------------------------
If anybody have a solution or comment i'll appreciate a lot.. Thanks.
David Alcaraz.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
General News Question Answer Joke &n
|