簡體   English   中英

從Visual Studio安裝程序的安裝安裝程序中取消安裝程序

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

我有一個安裝程序類,它在安裝時會引起用戶的注意。現在根據我的要求,如果提供的值不正確,我必須取消安裝,但我沒有得到如何安裝它的方法..

這是我的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);

        }
    }

盡管Rollback(stateSaver); 我的安裝程序已安裝。

請幫我..

僅調用InstallException即可進行回滾。 這是通常的方式,並且可以正常工作,因此,如果沒有,則說明正在進行其他操作。

您應該考慮使用另一個工具,該工具可讓您在輸入數據時驗證數據。 VS自定義操作始終在所有文件安裝完畢后運行,因此,基本上,您是先安裝整個應用程序,然后回滾它,而不是使用MSI構建工具驗證輸入時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM