Wix 自定义操作 - 会话为空且延迟操作出错 [英] Wix Custom Action - session empty and error on deferred action

查看:26
本文介绍了Wix 自定义操作 - 会话为空且延迟操作出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有 VS2017 扩展的 Wix 3.11.1.我从自定义 Dialogue 上的控件设置了一个属性,然后尝试立即执行自定义操作.当我尝试阅读会话时,它总是空的.

按照建议,我将操作更改为不同的执行,并使用立即操作来设置我的属性.当我运行安装程序时,出现错误:调试:错误 2896:执行操作 [ActionName] 失败."

在 CustomDialog.wxs 中

<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></控制><片段><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"/></片段>

在 Product.wxs 中

<Custom Action="SetPropertyForShowProperty" After="InstallInitialize"/><Custom Action="RegistrationInfoCustomAction" Before="InstallFinalize"/></InstallExecuteSequence>

在 CustomActions.cs 中

[自定义动作]公共静态 ActionResult SaveUserInfo(Session session){Debugger.Launch();CustomActionData 数据 = session.CustomActionData;session.Log("开始保存用户信息");var connectionString = data["CONN"];session.Log($"content: {connectionString}");session.Log("End SaveUserInfo");返回 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]:在调用 Install on Server 之前尝试启用所有禁用的权限

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]:执行操作:FatalError

解决方案

更新:已经晚了,我第一眼没有看到这个,但只有立即模式自定义操作可以从设置 GUI 运行.创建一个新的、立即模式自定义操作来为您的 PUBLIC 属性 CONN 设置一个值,然后通过类型 51 自定义操作设置 CONN 的值以分配给延迟模式自定义操作的 Id - 如下所述.

<小时><块引用>

SecureCustomProperties:通过设置 Secure="yes" 属性将您指定的属性添加到 SecureCustomProperties:

<Property Id="MYPROPERTY" Secure="yes">将此文本发送到延迟模式</Property>

<小时><块引用>

名称匹配:您分配值的属性名称必须与延迟模式自定义操作Id匹配.在您的来源中看起来不错.

更多技术:type 51 actionProperty 属性值 必须与使用 CustomActionData 的自定义操作:

<Property Id="MYPROPERTY" Secure="yes">将此文本发送到延迟模式</Property><!-- Type 51 CA:将 MYPROPERTY 的值发送到名为 MyAction 的延迟模式 CA --><CustomAction Id="MyAction.SetProperty" Return="check" Property="MyAction" Value="[MYPROPERTY]"/><!-- 延迟模式自定义操作--><CustomAction Id="MyAction" Return="check" Execute="deferred" BinaryKey="CAs" DllEntry="MyAction"/><!-- ... --><!-- 按顺序插入 CA--><安装执行序列><Custom Action="MyAction.SetProperty" After="InstallInitialize"/><Custom Action="MyAction" Before="InstallFinalize"/></InstallExecuteSequence>

这里有一些资源:

<小时>

仅供调试参考.您可以使用:string data = session["CustomActionData"];

<小时>

告诉您什么,让我插入代码以使用 VBScript 进行测试,以便您可以使用消息框.应该没有必要,以防万一您有调试问题:

VBScript "Simple.vbs"(另存为文件):

MsgBox Session.Property("CustomActionData")

WiX 标记更改:

<CustomAction Id="MyAction" Return="check" Execute="deferred" BinaryKey="Simple.vbs" VBScriptCall=''/>

以防万一这更容易.建议您仅使用 VBScript 进行调试.当我想消除所有其他错误源时,我喜欢 VBScript 获得heartbeat".

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

解决方案

UPDATE: It is late, I didn't see this on first sight, but only immediate mode custom actions can be run from the setup GUI. Make a new, immediate mode custom action to set a value to your PUBLIC property CONN, and then set the value of CONN via a type 51 custom action to be assigned to the Id of the deferred mode custom action - as described below.


SecureCustomProperties: Add the property you specify to SecureCustomProperties by setting the Secure="yes" attribute:

<Property Id="MYPROPERTY" Secure="yes">Send this text to deferred mode</Property>


Name Match: the property name you assign the value to must match the deferred mode custom action Id. Looks OK in your source.

More Technical: the Property attribute's value of the type 51 action must be identical to the Id of the custom action that is consuming CustomActionData:

<!-- Declare property with value -->
<Property Id="MYPROPERTY" Secure="yes">Send this text to deferred mode</Property>

<!-- Type 51 CA: Send value of MYPROPERTY to the deferred mode CA named MyAction -->
<CustomAction Id="MyAction.SetProperty" Return="check" Property="MyAction" Value="[MYPROPERTY]" />

<!-- The deferred mode custom action -->
<CustomAction Id="MyAction" Return="check" Execute="deferred" BinaryKey="CAs" DllEntry="MyAction" />

<!-- ... -->

<!-- Inserting the CAs in sequence -->
<InstallExecuteSequence>
    <Custom Action="MyAction.SetProperty" After="InstallInitialize" />
    <Custom Action="MyAction" Before="InstallFinalize" />
</InstallExecuteSequence>

Here are some resources:


Just for debugging reference. And you can use: string data = session["CustomActionData"];


Tell you what, let me slide in the code to test using VBScript so you can use message boxes. Should not be necessary, just in case you have a debugging issue:

VBScript "Simple.vbs" (save as file):

MsgBox Session.Property("CustomActionData")

WiX markup change:

<Binary Id='Simple.vbs' SourceFile='Simple.vbs' />
<CustomAction Id="MyAction" Return="check" Execute="deferred" BinaryKey="Simple.vbs" VBScriptCall='' />

Just in case that is easier. Recommend you use VBScript for debugging only. I like VBScript to get a "heartbeat" when I want to eliminate all other error sources.

这篇关于Wix 自定义操作 - 会话为空且延迟操作出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆