WiX install error 2762 while invoking a CustomAction from dialog

*爱你&永不变心* 提交于 2019-12-05 11:20:50

问题


I am a beginner, started learning WiX. I want to capture and validate and register user details during the installation process. I have created a dialog to capture user registration and invoking a custom action once user clicks on 'Next'.

But here I am getting installer error 2762. Though the error description says that "The action must be scheduled between InstallInitialize and InstallFinalize", I am not able to figure out how to resolve this problem.

Here is my XML script:

<Binary Id="mycustom"
        SourceFile="..\CustomAction1\bin\Debug\CustomAction1.CA.dll" />

<CustomAction Id="myCustomValidate"
              BinaryKey="mycustom"
              DllEntry="ValidateCustomAction"
              Execute="deferred"
              Return="check">
</CustomAction>

<UI>
    <UIRef Id="WixUI_Mondo" />
    <Dialog Id="UserRegistrationDlg"
            Width="370"
            Height="270"
            Title="[ProductName] [Setup]"
            NoMinimize="yes">
        ..
        ..
        ..
        <Control Id="Next"
                 Type="PushButton"
                 X="236"
                 Y="243"
                 Width="56"
                 Height="17"
                 Default="yes"
                 Text="[ButtonText_Next]">
            <Publish Event="ValidateProductID" Value="0">1</Publish>
            <Publish Event="DoAction" Value="myCustomValidate">1</Publish>
            <Publish Event="SpawnDialog" Value="InvalidRegDlg">PIDACCEPTED = "0"</Publish>
            <Publish Event="NewDialog" Value="SetupTypeDlg">ProductID AND PIDACCEPTED = "1"</Publish>
        </Control>
    </Dialog>
</UI>

Following is the custom action code I used.

[CustomAction]
public static ActionResult ValidateCustomAction(Session session)
{
    return ActionResult.Success;
}

Custom action is working fine if used in "InstallExecuteSequence". I am not able to figure out the problem, I removed the custom dialog and used the following simple call to invoke custom action. But I ended up with the same error.

<Publish Dialog="LicenseAgreementDlg"
         Control="Next"
         Event="DoAction"
         Value="myCustomValidate">1</Publish>

I am sure I am doing something silly here, but couldn't figure out. What is the solution?


回答1:


In your CustomAction element set Execute attribute to immediate. Deferred actions can run only in InstallExecuteSequence between InstallInitialize and InstallFinalize actions.



来源:https://stackoverflow.com/questions/8585918/wix-install-error-2762-while-invoking-a-customaction-from-dialog

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