Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 执行InstallerClass';时找不到installstate错误;安装项目中的s Roolback事件_C#_Setup Project_Custom Action_Uninstallation - Fatal编程技术网

C# 执行InstallerClass';时找不到installstate错误;安装项目中的s Roolback事件

C# 执行InstallerClass';时找不到installstate错误;安装项目中的s Roolback事件,c#,setup-project,custom-action,uninstallation,C#,Setup Project,Custom Action,Uninstallation,我创建了一个VisualStudio安装项目,并将两个控制台应用程序作为项目输出添加到安装项目中。每个控制台应用程序都有其installerclass。在安装项目的自定义操作中,我添加了以上两个应用程序 在ConsoleEapp2的InstallerClass中,我有一些验证,如果验证成功,那么它将验证ConsoleEapp1的InstallerClass,否则安装程序应回滚 在回滚操作期间,我收到如下“错误1001.找不到文件app path\Consoleapp1.InstallState”

我创建了一个VisualStudio安装项目,并将两个控制台应用程序作为项目输出添加到安装项目中。每个控制台应用程序都有其installerclass。在安装项目的自定义操作中,我添加了以上两个应用程序

在ConsoleEapp2的InstallerClass中,我有一些验证,如果验证成功,那么它将验证ConsoleEapp1的InstallerClass,否则安装程序应回滚

在回滚操作期间,我收到如下“错误1001.找不到文件app path\Consoleapp1.InstallState”,因为它的InstallState尚未启动

有没有办法解决这个问题。我的主要座右铭是,如果installerclass中的验证失败,将回滚安装而不向用户显示错误。下面是我正在使用的代码

  public override void Install(IDictionary stateSaver)
    {
        base.Install(stateSaver);
        MessageBox.Show("Install");
        try
        {
            const string subkey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\";

            using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(subkey))
            {
                if (ndpKey != null && ndpKey.GetValue("Release") != null && Convert.ToInt32(ndpKey.GetValue("Release")) > 461310)
                {
                    MessageBox.Show("Framework version is " + ndpKey.GetValue("Release").ToString());

                    string message = "This setup requires .Net framework Version 4.7.1. Please install the .Net Framework and run setup again. The .Net framework can be  obtained from the web. Would you like to do this now ?";
                    MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                    DialogResult result = MessageBox.Show(message, "", buttons);
                    if (result == DialogResult.Yes)
                    {
                        Process.Start("http://go.microsoft.com");

                        throw new InstallException(String.Format("Installation rollbacked."));
                    }
                    else
                    {
                        throw new InstallException(String.Format("Cancelling Installation"));

                    }

                }
                else
                {


                }

            }
        }
        catch (Exception ex)
        {

            throw new Exception(String.Format("Cancelling Installation 123"));

        }

    }
    public override void Rollback(IDictionary savedState)
    {
        base.Rollback(savedState);
        MessageBox.Show("rollback c2 " + savedState.Values);
    }
    public override void Uninstall(IDictionary savedState)
    {
        base.Uninstall(savedState);
    }
    public override void Commit(IDictionary savedState)
    {
        base.Commit(savedState);
    }