Stop setup error inside Custom Action With WIX installer

主宰稳场 提交于 2020-01-30 02:58:31

问题


Can i able to stop the setup if any error display inside CustomAction. As i can able display error message inside custom Action and it's dispaly the error message but as soon as i click on ok button my next UI sequence form is appearing.How i will force user to finish button?

Adding my source code:

<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;
            }



        }

Add screen shot also proving once i click on Ok button of image(1) my next dialog i.e image (2) is appearing:- instead of what i need is Finish dialog when i am getting the error.

1)

2)

Any idea??kindly help me.

回答1:


This is an old post but I'd like to answer the question in case somebody else finds this. In the custom action definition, CustomAction Id="CA_CheckList" BinaryKey="BIN_CustomAction" ..., 'Return' is set to 'ignore'. It should be set to 'check'.




回答2:


It's all about returning the correct "error code" from the custom action. If you want to terminate the installation, return ActionResult.Failure from your CA.

Side note: displaying UI from inside the custom action is generally a bad idea - this scenario doesn't support silent installation the way it should go.



来源:https://stackoverflow.com/questions/17401785/stop-setup-error-inside-custom-action-with-wix-installer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!