日期:2014-05-20  浏览次数:20751 次

部署中的自定义操作怎么弄? 走投无路,十万火急。
我想试试在安装包装完后弹出一个helloworld的程序,就是最最简单的那种。

就在自定义操作->安装 下加了hello.exe,但装的时候为什么不执行呢?




另外求个思路,http://topic.csdn.net/u/20100410/15/9faa37cc-42b0-4fa3-ac75-63be2e722153.html,谢谢大家。



------解决方案--------------------
直接用exe是不行的.具体步骤应该是:
一.制作自定义操作Dll:
1.在解决方案里面添加一个类型是类库的新项目,假设为AfterInstall;
2.在引用里面添加System.Configuration.Install;
3.在这个类库里面做好你需要弹出的窗口以及用户界面等,如果没有必要,可省略;
4.加入一个继承自Installer的类
C# code

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

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

        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);
        }

        public override void Commit(System.Collections.IDictionary savedState)
        {
            base.Commit(savedState);

            //弹出窗口,让用户配置连接数据库的连接字符串

             //从状态上下文获得程序安装的路径,tar的来源详见下面步骤
            string targetdir = this.Context.Parameters["tar"].ToString();

            DataManagement dmf = new DataManagement(targetdir);
            dmf.ShowDialog();
        }
    }
}