2013-07-01 137 views
1

如果在CustomAction中顯示任何錯誤,我能否停止安裝程序。因爲我可以顯示自定義操作內的錯誤消息,它顯示錯誤消息,但只要我點擊確定按鈕我的下一個UI序列窗體出現。我將如何強制用戶完成按鈕?在自定義操作中停止安裝錯誤使用WIX安裝程序

添加我的源代碼:

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



     } 

添加屏幕截圖也再次證明我點擊圖像的OK按鈕(1)我的下一個對話框,即圖像(2)出現: - 而不是我需要的是當我收到錯誤時完成對話框。

1)Error Message appears

2)Next Dialog

Any idea??kindly help me. 

回答

2

這一切都從自定義操作返回正確的 「錯誤代碼」。如果您想終止安裝,請從CA返回ActionResult.Failure

備註:從自定義操作內部顯示UI通常是一個糟糕的主意 - 此方案不支持靜音安裝。

+0

當我嘗試使用ActionResult.Failure它仍然顯示的下一個按鈕,而不是完成button.What可能是這個可能的修復? – reapen

+0

有沒有什麼我需要做的內部安裝UI序列如果ActionResult是失敗目前這是我正在做什麼 未安裝 reapen

+0

我不理解你的問題。當您從自定義操作返回'ActionResult.Failure'時,通常會回滾安裝。根據您使用的UI,它將顯示或不顯示最終的「安裝失敗」對話框。 AFAIK,完整的UI方案包含您的場景所需的所有對話框。 –

3

這是一箇舊的帖子,但我想回答這個問題,以防其他人發現這種情況。在自定義操作定義中,CustomAction Id =「CA_CheckList」BinaryKey =「BIN_CustomAction」...,'Return'設置爲'ignore'。它應該被設置爲'檢查'。

相關問題