| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3039 人关注过本帖
标题:安装程序类 Installer 问题
只看楼主 加入收藏
rinoa007
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-3-23
结帖率:0
收藏
已结贴  问题点数:20 回复次数:3 
安装程序类 Installer 问题
protected override void OnBeforeInstall(System.Collections.IDictionary savedState)
        {
            base.OnBeforeInstall(savedState);
           if (一定结果)
            {
            base.Uninstall(savedState);
            或者这样//this.Uninstall(savedState);
//如果判断结果是真,则执行这句,就是中止继续安装,回到开始状态,现在遇到的问题,他会抛出一个异常对话框(上面两种写法都是),然后点击确定,则这安装程序回到安装程序的初始状态即终止了继续安装,达到了终止继续安装的效果,但是这个异常对话框怎么去掉阿,或是base.Uninstall(savedState);这样写在这里就不对,那位做过这块的,给点提示,谢谢!

            }
        }

现在的问题就是在Installer这里面根据条件终止正在安装的程序,回滚到安装的初时状态?
搜索更多相关主题的帖子: Installer 
2010-03-23 23:31
zhuyunshen
Rank: 6Rank: 6
等 级:侠之大者
威 望:2
帖 子:212
专家分:455
注 册:2009-11-22
收藏
得分:20 
没做过
2010-03-23 23:52
rinoa007
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-3-23
收藏
得分:0 
我打算在做安装程序中加一个输入序列号的页面,判断如果输入错误,就不让它安装下去了。怎么做也不行!

using System;
using System.Collections;
using System.Collections.Generic;
using
using System.Configuration.Install;
using System.Linq;


namespace WebSetupConponent
{
    [RunInstaller(true)]
    public partial class Installer1 : Installer
    {
        public Installer1()
        {
            InitializeComponent();

            this.BeforeInstall += new InstallEventHandler(Installer1_BeforeInstall);
            this.AfterInstall += new InstallEventHandler(Installer1_AfterInstall);

             += new InstallEventHandler(Installer1_Committing);
             += new InstallEventHandler(Installer1_Committed);

            this.BeforeUninstall += new InstallEventHandler(Installer1_BeforeUninstall);
            this.AfterUninstall += new InstallEventHandler(Installer1_AfterUninstall);
        }

        private void Installer1_BeforeInstall(object sender, InstallEventArgs e)
        {

        }
        private void Installer1_AfterInstall(object sender, InstallEventArgs e)
        {
            Form1 _FC = new Form1();
            _FC.ShowDialog();

            if (_FC.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                //继续安装程序
            }
            else
            {
                //退出安装程序
            }
        }
        private void Installer1_Committing(object sender, InstallEventArgs e)
        {

        }
        private void Installer1_Committed(object sender, InstallEventArgs e)
        {

        }
        private void Installer1_BeforeUninstall(object sender, InstallEventArgs e)
        {

        }
        private void Installer1_AfterUninstall(object sender, InstallEventArgs e)
        {

        }

        protected override void OnAfterInstall(IDictionary savedState)
        {
            Form1 _FC = new Form1();
            _FC.ShowDialog();

            if (_FC.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                base.OnAfterInstall(savedState);
            }
            else
            {
                //base.Uninstall(savedState); 发生错误
                //base.Rollback(savedState);  发生错误               
            }
        }
        public override void Install(IDictionary stateSaver)
        {
            base.Install(stateSaver);
        }
        protected override void OnBeforeInstall(IDictionary savedState)
        {
            Form1 _FC = new Form1();
            _FC.ShowDialog();

            if (_FC.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                base.OnBeforeInstall(savedState);
            }
            else
            {
                //base.Uninstall(savedState);   发生错误
                //base.Rollback(savedState);    发生错误            
            }
        }
        public override void Uninstall(IDictionary savedState)
        {
            base.Uninstall(savedState);
        }
        public override void Rollback(IDictionary savedState)
        {
            base.Rollback(savedState);
        }
    }
}
2010-03-24 00:30
rinoa007
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-3-23
收藏
得分:0 
看了台湾一位写的文章,也好像没有解决方法?
http://blog.   难道真的没办法做到?
2010-03-24 00:31
快速回复:安装程序类 Installer 问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024436 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved