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




        ApplicationDeployment ad;

        private void cbUpdate_Click(object sender, EventArgs e)


            ad = ApplicationDeployment.CurrentDeployment;

            ad.CheckForUpdateCompleted += new


            //Event to show the progressbar

            ad.UpdateProgressChanged += new


            //Event to restart the application,

            //otherwise changes will not reflect

            ad.UpdateCompleted += new

               AsyncCompletedEventHandler ad_UpdateCompleted);

            //Call the method to invoke the update process



        void ad_UpdateCompleted(object sender, AsyncCompletedEventArgs e)




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








For more reference visit,d=ide).aspx#Mtps_DropDownFilterText