ClickOnce Deployment : System.Deployment API

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

            }


        }


    }


}

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
com.bes.enterprise.appserv.deployment.exception.StartupFailedException: Exception occurred while starting the application. at com.bes.enterprise.appserv.deployment.manager.AppDeployManager$2.run(AppDeployManager.java:253) at com.bes.enterprise.appserv.deployment.manager.AppDeployManager.applyDeploymentContext(AppDeployManager.java:297) at com.bes.enterprise.appserv.deployment.manager.AppDeployManager.doLoad(AppDeployManager.java:245) at com.bes.enterprise.appserv.deployment.manager.ApplicationLifecycle.load(ApplicationLifecycle.java:77) at com.bes.enterprise.appserv.deployment.AppDeployer.load(AppDeployer.java:264) at com.bes.enterprise.appserv.deployment.handler.EnableApplicationHandler.doLoad(EnableApplicationHandler.java:133) at com.bes.enterprise.appserv.deployment.handler.EnableApplicationHandler.load(EnableApplicationHandler.java:71) at com.bes.enterprise.appserv.deployment.handler.EnableApplicationHandler.doApplicationProcess(EnableApplicationHandler.java:54) at com.bes.enterprise.appserv.deployment.handler.AbstractApplicationHandler$1.call(AbstractApplicationHandler.java:69) at com.bes.enterprise.appserv.deployment.handler.AbstractApplicationHandler$1.call(AbstractApplicationHandler.java:66) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750) at com.bes.enterprise.appserv.deployment.handler.AbstractApplicationHandler$TerminableThread.run(AbstractApplicationHandler.java:177) Caused by: com.bes.enterprise.ejb.BESException: Creating application failed: /besweb/webapp/prpall: ContainerBase.addChild: start: com.bes.enterprise.webtier.LifecycleException: Failed to start component [WebEngine[com.bes.appserv].VirtualHost[server].DefaultContext[/prpall]] at com.bes.enterprise.ejb.assembler.classic.assemblercontext.ApplicationDeployer.doCreateApplication(ApplicationDeployer.java:458) at com.bes.enterprise.ejb.assembler.classic.assemblercontext.ApplicationDeployer.createApplication(ApplicationDeployer.java:342) at com.bes.enterprise.ejb.assembler.classic.assemblercontext.ApplicationDeployer.createApplication(ApplicationDeployer.java:331) at com.bes.enterprise.ejb.assembler.classic.Assembler.createApplication(Assembler.java:258) at com.bes.enterprise.appserv.deployment.manager.AppDeployManager$2.run(AppDeployManager.java:251) ... 14 more Caused by: java.lang.IllegalStateException: ContainerBase.addChild: start: com.bes.enterprise.webtier.LifecycleException: Failed to start component [WebEngine[com.bes.appserv].VirtualHost[server].DefaultContext[/prpall]] at com.bes.enterprise.webtier.core.ContainerBase.addChildInternal(ContainerBase.java:745) at com.bes.enterprise.webtier.core.ContainerBase.addChild(ContainerBase.java:717) at com.bes.enterprise.webtier.core.DefaultHost.addChild(DefaultHost.java:711) at com.bes.enterprise.webext.BESWebAppBuilder.deployWebApps(BESWebAppBuilder.java:511) at com.bes.enterprise.ejb.assembler.classic.assemblercontext.ApplicationDeployer.deployWebApps(ApplicationDeployer.java:1499) at com.bes.enterprise.ejb.assembler.classic.assemblercontext.ApplicationDeployer.doCreateApplication(ApplicationDeployer.java:437) ... 18 more
最新发布
07-25
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值