【问题标题】:Debugging (Stepping through) a VS setup project, How do you do it?调试(单步调试)一个 VS 安装项目,你是怎么做的?
【发布时间】:2014-06-04 15:19:07
【问题描述】:

我正在尝试调试我在 c# (VS) 中创建的安装项目...我将项目当前设置为“调试”而不是“发布”,并且我已将以下代码添加到我的自定义操作区域。 ..

public override void Install(System.Collections.IDictionary stateSaver)
{
    if (Debugger.IsAttached == false) Debugger.Launch();
    MessageBox.Show("Installing Application...");

    //Continue with install process
    base.Install(stateSaver);
}

//Code to perform at the time of uninstalling application 
public override void Uninstall(System.Collections.IDictionary savedState)
{
    if (Debugger.IsAttached == false) Debugger.Launch();
    MessageBox.Show("Uninstalling Application...");

    //Continue with uninstall process
    base.Uninstall(savedState);
}

当我去安装时(右键单击设置项目-> 安装)它按预期工作,我可以使用 F11 逐步完成每一行。当我去卸载(右键单击设置项目->卸载)时,它不会让我使用 F11 或继续使用 F5 或查看任何智能感知弹出窗口(如变量值等)。虽然我可以单击文件菜单选项来执行每个操作(调试->继续和调试->单步执行)。

任何想法为什么会出现这种情况以及我如何能够获得该功能?

其他问题:是否可以像使用普通程序一样在运行时单步执行安装项目时更改任何代码(例如添加消息框)?

【问题讨论】:

    标签: c# visual-studio-2010 installation custom-action


    【解决方案1】:

    解决方案: 就我而言,我试图调试我的自定义安装操作 Install() 和 Uninstall()。我最终将以下内容添加到我的自定义操作中......

    if (Debugger.IsAttached == false) Debugger.Launch();
    

    这很简单,下面是它的一个例子......

    //Code to perform at the time of installing application
    public override void Install(System.Collections.IDictionary stateSaver)
    {
        if (Debugger.IsAttached == false) Debugger.Launch();
    
        CustomParameters cParams = new CustomParameters();
        cParams.Add("InstallPath", this.Context.Parameters["targetdir"]);
        cParams.SaveState(stateSaver);
    
        //Continue with install process
        base.Install(stateSaver);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-07
      • 2010-09-06
      • 1970-01-01
      相关资源
      最近更新 更多