DoAction 更新文本 [英] DoAction to update text

查看:30
本文介绍了DoAction 更新文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在对话框上的 Wix 更新文本中设置自定义操作?我一直在寻找执行此操作的各种方法,但没有任何方法对我有用.

Is it possible to have a custom action in Wix update text on a dialog? I've been searching various methods of doing this, but nothing has worked for me yet.

我有一个用

<Control Id="RunButton" Type="PushButton" X="0" Y="0" Height="18" Width="56" Text="Run">
    <Publish Event="DoAction" Value="CustomAction">1</Publish>
</Control>

和具有

<Control Id="MessageText" X="0" Y="20" Width="100" Height="18">
    <Subscribe Event="ActionData" Attribute="Text" /> 
</Control>

在我的自定义操作中,我有

In my custom action, I have

using(var rec = new Record(0)){
    rec.SetString(0, "Starting...");
    session.Message(InstallMessage.ActionData, rec);
}

这是我在许多论坛上找到的基本流程,但对我不起作用.

This is the basic process I've found on numerous forums, but it isn't working for me.

动作定义为 Execute="immediate" 和 Return="Check".

The action is defined as Execute="immediate" and Return="Check".

我还尝试将记录"对象更改为 3 个字段,并将相同的属性设置为字段 1、2 和 3.这也不起作用.

I have also tried changing the "Record" object to be 3 fields, and set the same property to fields 1, 2 and 3. That did not work either.

谁能解释一下我做错了什么?这在 Wix 中是不可行的吗?本质上,我试图在自定义操作中设置一个长时间运行的流程,并希望能够向用户报告操作的进度.

Could anyone explain what I'm doing wrong? Is this just not doable in Wix? Essentially I am trying to set up a long running process in a custom action and want to be able to report back to the user the progress of the action.

推荐答案

如果您查看 DoAction 的文档:

If you check the docs for DoAction:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa368322(v=vs.85).aspx

它说你不能通过 MsiProcessMessage 发送消息,这就是 session.message 实际上在下面的内容,所以这是它不起作用的最可能的原因.我怀疑您正在查看的论坛描述了 MsiProcessMessage 的一般用法,而没有对这种特殊情况进行警告.

it says that you can't send a message via MsiProcessMessage, which is what session.message actually is underneath, so that's the most likely reason for it not working. I suspect that the forums you're looking at describe general use of MsiProcessMessage without the caveat of this particular case.

在不知道自定义操作在做什么的情况下,我无法提出任何建议.在执行序列中,您可以将 CA 与进度条集成,但您处于 UI 序列中,大概是在收集大量数据或检查某些内容.

Without knowing what the custom action is doing I can't suggest anything. In the execute sequence you can integrate your CA with the progress bar, but you're in the UI sequence, presumably collecting a lot of data or checking something.

如果您的自定义操作更新系统,它应该作为延迟自定义操作在执行序列中.这不仅可以让您影响进度条并提供说明正在发生的事情的文本,而且安装可能会失败,或者用户可以取消它,事务安装的全部意义在于失败会回滚它,就好像安装永远不会一样开始了.这意味着您应该保存数据库并在回滚自定义操作中恢复它.您可能遇到的另一个问题是 UI 中的即时自定义操作没有提升,因此您可能无法更新数据库.不仅如此,静默安装会绕过 UI,因此不会调用您的自定义操作,并且无法使用组策略或 SCCM 方法推出您的产品.

If your custom action updates the system it should be in the execute sequence as a deferred custom action. Not only does that let you influence the progress bar and supply text saying what's going on, but the install could fail, or the user could cancel it, the whole point of a transactional install is that failure will roll it back as if the install never started. That means you should save the database and restore it in a rollback custom action. The other issue you might have is that immediate custom actions in the UI are not elevated, so you may not be able to update the database. Not only that, but a silent install bypasses the UI so your custom action won't be called and your product cannot be rolled out using group policy or SCCM methods.

这篇关于DoAction 更新文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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