首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >取消安装程序在Visual Studio安装程序中安装安装程序

取消安装程序在Visual Studio安装程序中安装安装程序
EN

Stack Overflow用户
提问于 2014-05-15 18:17:33
回答 1查看 1.2K关注 0票数 0

我有一个installer类,它根据我的要求在installation.Now时从用户那里获取一个值,如果提供的值不正确,我必须取消安装,但我不知道如何获得它。

这是我的installer.cs文件..

代码语言:javascript
运行
复制
 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);

        }
    }

尽管安装了Rollback(stateSaver);,我的安装程序还是安装了..

请帮帮我..

EN

回答 1

Stack Overflow用户

发布于 2014-05-15 22:17:22

只需调用InstallException即可执行回滚。这是通常的方式,它起作用了,所以如果它不起作用,那么一定是发生了其他事情。

您应该考虑使用另一个工具,让您在输入数据时对其进行验证。VS自定义操作总是在所有文件安装完成后运行,所以基本上你是在安装整个应用程序,然后回滚它,而不是使用MSI构建工具,让你在进入应用程序时进行验证。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23675391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档