ClickOnce Deployment : System.Deployment API
Applied to: Visual Studio 2005
ClickOnce is the deployment revolution for SmartClient applications. This is very cost effective solution for Smart Client applications. Support cost is very less and the deployment is per user basis. So user does not need Administrator right to install the application and security sandboxing is integral part to it. Automatic update notification can be implemented easily. One server is enough for n number of user installation. We can enjoy the power of windows application at the cost of Web Application.
The automatic update has one problem in it. If you skip the update notification next time it won’t popup the notification for you. That means if the update is critical you may need to uninstall the application and the install form the server location. Also if you rollback the installation (can be done from Add/Remove Program) you won’t get the notification for latest update. But it can be solved by ClickOnce version number. That means you can tell your smart client application that user need to have minimum version at their machine to run.
That’s why the extensibility comes into the picture. We need to give option for the end user that they can download and install the application on demand. In wizard we cannot do much of it but we have System.Deployment API for it. This API helps us to write our own code especially for on demand installations.
The below example shows how to do it, (I have added a button in my code to run the on demand installation, you can add this functionality to your application’s menu). You need to implement the namespace System.Deployment.Application.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Deployment.Application;
namespace ClickOnce_MSDN
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
ApplicationDeployment ad;
private void cbUpdate_Click(object sender, EventArgs e)
{
ad = ApplicationDeployment.CurrentDeployment;
ad.CheckForUpdateCompleted += new
CheckForUpdateCompletedEventHandler(ad_CheckForUpdateCompleted);
//Event to show the progressbar
ad.UpdateProgressChanged += new
DeploymentProgressChangedEventHandler(ad_UpdateProgressChanged);
//Event to restart the application,
//otherwise changes will not reflect
ad.UpdateCompleted += new
AsyncCompletedEventHandler ad_UpdateCompleted);
//Call the method to invoke the update process
ad.CheckForUpdateAsync();
}
void ad_UpdateCompleted(object sender, AsyncCompletedEventArgs e)
{
Application.Restart();
}
//to show the progressbar
void ad_UpdateProgressChanged(object sender,
DeploymentProgressChangedEventArgs e)
{
this.progressBar1.Value = e.ProgressPercentage;
}
void ad_CheckForUpdateCompleted(object sender,
CheckForUpdateCompletedEventArgs e)
{
if (e.UpdateAvailable)
{
//Async UPDATE
ad.UpdateAsync();
}
}
}
}
Reference:
For more reference visit
Comments
Anonymous
February 06, 2008
ClickOnce is a good technology. Biggest Drawback is , there is no option to use our own folder on the client machine. It is always updated in ClickOnce Application Cache. Is there anyway to change it... I have seen many blogs no idea till now.. Not even through code. For me it not usable coz of this limitation.Anonymous
March 27, 2008
same problem i am facing which bhoomi faced. The drawback of clickones is that application is installed in a directory managed by .net framework. in current user's account, not in programm folders as we do with windows installer deployment. When user logged in computer with a different account, he has to reinstall the prograam. is there no any way to have the windows installer strength with click ones diploymentAnonymous
March 31, 2008
Click Once installes apps per user. That is by design. We have no option to alter. If you require to install it for all the users then you need to use MSI.Anonymous
March 31, 2008
Click Once installes apps per user. That is by design. We have no option to alter. If you require to install it for all the users then you need to use MSI.Anonymous
March 31, 2008
Click Once installes apps per user. That is by design. We have no option to alter. If you require to install it for all the users then you need to use MSI.Anonymous
March 31, 2008
Click Once installes apps per user. That is by design. We have no option to alter. If you require to install it for all the users then you need to use MSI.Anonymous
July 21, 2008
Is there any way to clear the Application Cache before client is installing the new version. I have many clients who are getting issues with Cache(contact application vendor), then i ask them to clear the cache and install again. Rather than doing that, is it possible to do the below Step 1 clear the cache Ste p2 is install new version.Anonymous
August 04, 2008
A chi potesse interessare, è disponibile il codice e la descrizione di queste funzionalità in italiano all'indirizzo http://www.vbdotnet.it/post/2008/08/05/Creare-un-LiveUpdate-dalle-proprie-applicazioni.aspxAnonymous
October 05, 2009
I am using clickonce deployment for WPF application. It is working fine…. The only issue, IE is prerequisite for this… I want to make it working on a machine , which doesn’t have IE installed on it...