使用WIX安装程序在自定义操作中停止设置错误

时间:2013-07-01 10:03:12

标签: wix wix3.5 wix3 wix3.6

如果CustomAction中显示任何错误,我是否可以停止设置。因为我可以在自定义操作中显示错误消息,它显示错误消息但是一旦我点击确定按钮,我的下一个UI序列表格就出现了。如何强制用户完成按钮?

添加我的源代码:

<Binary Id="BIN_CustomAction" SourceFile="CustomAction.CA.dll" />
        <CustomAction Id="CA_CheckList" BinaryKey="BIN_CustomAction" DllEntry="CA_CheckList" Execute="immediate" Impersonate="yes" Return="ignore" />

       <UI Id="MyWixUI_Mondo">
            <UIRef Id="WixUI_Mondo" />
            <UIRef Id="WixUI_ErrorProgressText" />
            <DialogRef Id="UserRegistrationDlg" />
            <Dialog Id="UserRegistrationDlg" Width="370" Height="270" Title="[ProductName] Setup" NoMinimize="yes">

                <Control Id="ComboBoxMain" Type="ComboBox" X="124" Y="158" Width="241" Height="16" Property="LOCATIONNAME">
                </Control>
                <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
                    <Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
                </Control>


                <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
                    <Publish Event="SpawnDialog" Value="SetupTypeDlg">1</Publish>
                </Control>
                <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
                    <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
                </Control>

            </Dialog>

            <Control Id="Next" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;NExt">
              <Publish Event="DoAction" Value="RadioButtonCheck">1</Publish>
            </Control>
          </Dialog>-->
            <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="UserRegistrationDlg" Order="3">
        LicenseAccepted = "1" 
      </Publish>
            <Publish Dialog="SetupTypeDlg" Control="Back" Event="NewDialog" Value="UserRegistrationDlg">1</Publish>
        </UI>
        <InstallUISequence>
            <Custom Action="CA_CheckList" Before="AppSearch">Not Installed</Custom>
        </InstallUISequence>

         [CustomAction]
        public static ActionResult CA_CheckList(Session session)
        {


            if (installer.ListStatus == false) 
            {

                // dispaly
                Record record = new Record();
                record.FormatString = string.Format("Error!");

                session.Message(
                   InstallMessage.Error | (InstallMessage)(MessageIcon.Error) |
                   (InstallMessage)MessageButtons.OK,record);

                return  ActionResult.Failure;   

            }
            else
            {
              return  ActionResult.Success;
            }



        }

添加屏幕截图也证明一旦我点击图像的确定按钮(1)我的下一个对话框,即图像(2)出现: - 当我收到错误时,而不是我需要的是完成对话框。

1)Error Message appears

2)Next Dialog

Any idea??kindly help me.

2 个答案:

答案 0 :(得分:3)

这是一篇很老的帖子,但我想回答这个问题,以防其他人发现这个问题。在自定义操作定义中,CustomAction Id =&#34; CA_CheckList&#34; BinaryKey =&#34; BIN_CustomAction&#34; ......,&#39;返回&#39;被设置为忽略&#39;。应将其设置为“检查”。

答案 1 :(得分:2)

这是关于从自定义操作返回正确的“错误代码”。如果要终止安装,请从CA返回ActionResult.Failure

附注:从自定义操作内部显示UI通常是一个坏主意 - 此方案不支持静默安装。