I am using Wix 3.11.1 with VS2017 Extension. I set a property from a control on a custom Dialogue and then try to execute an immediate custom action. When I try to read the session, it is always empty.
As recommended I changed my action to differed execution and used an immediate action to set my property. When I run my installer I get the error: "DEBUG: Error 2896: Executing action [ActionName] failed."
In CustomDialog.wxs
<Control Id="ConnId" Type="Edit" X="60" Y="110" Height="17" Width="300" Property="CONN"/>
<Control Id="installButton" Type="PushButton" Text="Continue" Height="15" Width="60" X="240" Y="260">
<Publish Event="DoAction" Value="RegistrationInfoCustomAction">1</Publish>
<Publish Event="EndDialog" Value="Return">1</Publish>
</Control>
<Fragment>
<Binary Id="CustomActionBinary" SourceFile="..\..\CustomActions\bin\Debug\CustomActions.CA.dll"/>
<CustomAction Id="SetPropertyForShowProperty" Property="RegistrationInfoCustomAction" Execute="immediate" Value="[CONN]" Return="check" />
<CustomAction Id="RegistrationInfoCustomAction" BinaryKey="CustomActionBinary" DllEntry="SaveUserInfo" Execute="deferred" Return="check" HideTarget="no"/>
</Fragment>
In Product.wxs
<InstallExecuteSequence>
<Custom Action="SetPropertyForShowProperty" After="InstallInitialize"/>
<Custom Action="RegistrationInfoCustomAction" Before="InstallFinalize"/>
</InstallExecuteSequence>
In CustomActions.cs
[CustomAction]
public static ActionResult SaveUserInfo(Session session)
{
Debugger.Launch();
CustomActionData data = session.CustomActionData;
session.Log("Begin SaveUserInfo");
var connectionString = data["CONN"];
session.Log($"content: {connectionString}");
session.Log("End SaveUserInfo");
return ActionResult.Success;
}
The custom action works when it contains only logging statements but adding any other code make it fail. Also, the session is always empty.
In Installer Log:
MSI (c) (88:34) [16:30:21:255]: Invoking remote custom action. DLL: C:\Users\Andre\AppData\Local\Temp\MSIF1A3.tmp, Entrypoint: SaveUserInfo
MSI (c) (88:F8) [16:30:21:256]: Cloaking enabled.
MSI (c) (88:F8) [16:30:21:256]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (88:F8) [16:30:21:256]: Connected to service for CA interface.
Action ended 16:30:41: RegistrationInfoCustomAction. Return value 3.
DEBUG: Error 2896: Executing action RegistrationInfoCustomAction failed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: RegistrationInfoCustomAction, , Action ended 16:30:41: SetupDialog. Return value 3. MSI (c) (88:8C) [16:30:41:911]: Doing action: FatalError