2

我正在使用带有 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

4

1 回答 1

0

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


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

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

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

更多技术:必须与正在使用的自定义操作的 Idthe Property attribute's value相同:type 51 actionCustomActionData

<!-- 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>

以下是一些资源:


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


告诉你什么,让我插入代码以使用 VBScript 进行测试,这样你就可以使用消息框了。不应该是必要的,以防万一您有调试问题:

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

MsgBox Session.Property("CustomActionData")

WiX 标记更改

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

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

于 2019-01-21T23:03:59.253 回答