我正在使用带有 VS2017 扩展的 Wix 3.11.1。我在自定义对话上设置控件的属性,然后尝试立即执行自定义操作。当我尝试阅读会话时,它总是空的。
按照建议,我将操作更改为不同的执行,并使用立即操作来设置我的属性。当我运行我的安装程序时,我收到错误:“调试:错误 2896:执行操作 [ActionName] 失败。”
在 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>
在 Product.wxs
<InstallExecuteSequence>
<Custom Action="SetPropertyForShowProperty" After="InstallInitialize"/>
<Custom Action="RegistrationInfoCustomAction" Before="InstallFinalize"/>
</InstallExecuteSequence>
在 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;
}
当自定义操作仅包含日志记录语句但添加任何其他代码使其失败时,它会起作用。此外,会话始终为空。
在安装程序日志中:
MSI (c) (88:34) [16:30:21:255]:调用远程自定义操作。DLL:C:\Users\Andre\AppData\Local\Temp\MSIF1A3.tmp,入口点:SaveUserInfo
MSI (c) (88:F8) [16:30:21:256]:启用隐形。
MSI (c) (88:F8) [16:30:21:256]:尝试在调用服务器上安装之前启用所有禁用的权限
MSI (c) (88:F8) [16:30:21:256]:连接到 CA 接口的服务。
操作于 16:30:41 结束:RegistrationInfoCustomAction。返回值 3。
调试:错误 2896:执行操作 RegistrationInfoCustomAction 失败。
安装程序在安装此软件包时遇到意外错误。这可能表明此软件包有问题。错误代码是 2896。参数是:RegistrationInfoCustomAction,,操作结束 16:30:41:SetupDialog。返回值 3. MSI (c) (88:8C) [16:30:41:911]: Doing action: FatalError