简体   繁体   English

从Visual Studio安装程序的安装安装程序中取消安装程序

[英]Cancelling Installer from Installing setup in Visual Studio Setup

I have a installer class which is taking a vale from the user at the time of installation.Now as per my requirement if the value provided is not correct i have to cancel the installation but i am not getting how to get this .. 我有一个安装程序类,它在安装时会引起用户的注意。现在根据我的要求,如果提供的值不正确,我必须取消安装,但我没有得到如何安装它的方法..

Here is my installer.cs file.. 这是我的installer.cs文件。

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

        // Retrieve configuration settings
        string targetSite = Context.Parameters["targetsite"];
        string targetVDir = Context.Parameters["targetvdir"];
        string targetDirectory = Context.Parameters["targetdir"];

        string value = Context.Parameters["value"];

        string connectionstring = Context.Parameters["db"];

        if (targetSite == null)
            throw new InstallException("IIS Site Name Not Specified!");

        if (targetSite.StartsWith("/LM/"))
            targetSite = targetSite.Substring(4);

        if (connectionstring == null)
            throw new InstallException("You did not specify a database to use!");

        if (value.Equals("123"))
        {

            RegisterScriptMaps(targetSite, targetVDir);
            ConfigureDatabase(targetSite, targetVDir, connectionstring);
        }

        else {

            Rollback(stateSaver);

        }
    }

Inspite of Rollback(stateSaver); 尽管Rollback(stateSaver); my setup gets installed.. 我的安装程序已安装。

Please help me.. 请帮我..

Just calling InstallException will do the rollback. 仅调用InstallException即可进行回滚。 That's the usual way and it works, so if it doesn't then something else is going on. 这是通常的方式,并且可以正常工作,因此,如果没有,则说明正在进行其他操作。

You should think about using another tool that lets you validate the data when it gets entered. 您应该考虑使用另一个工具,该工具可让您在输入数据时验证数据。 VS custom actions always run after all the files have been installed, so basically you're installing the entire app and then rolling it back rather than using an MSI build tool that lets you validate when it's entered. VS自定义操作始终在所有文件安装完毕后运行,因此,基本上,您是先安装整个应用程序,然后回滚它,而不是使用MSI构建工具验证输入时间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio安装程序安装项目从自定义操作执行回滚 - Visual studio installer setup project perform rollback from custom action Windows Installer Visual Studio安装项目 - Windows Installer Visual Studio Setup Project Visual Studio安装程序项目中的其他安装程序 - Additional Setup in Visual Studio Installer Projects Visual Studio 安装项目 - 生成的安装程序有问题 - Visual studio setup project - problem with the generated installer 在安装和部署类别中缺少Visual Studio安装程序 - Missing Visual Studio Installer in Setup & Deployment category 将 SQLLocalDB 包含到 Visual Studio 安装程序安装项目中 - Include SQLLocalDB into Visual Studio Installer Setup Project 使用安装项目Visual Studio安装程序安装应用程序后,图标未显示在任务栏中 - Icon not showing up in taskbar after installing an application with Setup project Visual studio installer 从Visual Studio安装项目安装SQL Server和.NET Framework - Installing SQL Server and .NET Framework from a visual studio setup project 什么是Visual Studio 2010安装项目中的“运行时实现来自ASSEMBLE NAME”? (vs 2015中的安装程序扩展设置项目) - what is “Runtime Implementation from ASSEMBLE NAME” in visual studio 2010 Setup Project? (Installer Extension Setup Project in vs 2015) Visual Studio 安装项目:在没有管理员权限的情况下运行 msi 安装程序 - Visual Studio Setup Project: Run the msi installer without administrator rights
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM