如何将自定义操作链接到控制事件
我正在研究 Wix 来构建产品安装程序。我已经成功自定义了 UI,但想知道如何链接自定义操作来控制事件(即 PushButton)。
我有 2 个项目:
Product.Wix.CustomActions
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");
MessageBox.Show("CustomActions1");
return ActionResult.Success;
}
Product.Wix.Setup (引用 Product.Wix.CustomActions 项目)。在Setup.wxs中,我声明了一个自定义操作:
<Binary Id="CustomActions" SourceFile="..\Product.Wix.CustomActions\bin\Debug\Product.Wix.CustomActions.CA.dll" />
<CustomAction Id='Action1' BinaryKey='CustomActions' DllEntry='CustomAction1' Execute='immediate' Return='check' />
我有一个带有“连接”按钮的自定义对话框,并连接到该操作,如下所示:
<Control Id="Connect" Type="PushButton" X="325" Y="75" Width="30" Height="17" Text="...">
<Publish Event="DoAction" Value="Action1">1</Publish>
</Control>
它没有像我预期的那样工作,当单击“连接”按钮时,它应该弹出一个消息框。
I'm studying Wix to build product installer. I've customized the UI successfully but be wondering how to link a custom action to control event (i.e PushButton).
I have 2 projects:
Product.Wix.CustomActions
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("Begin CustomAction1");
MessageBox.Show("CustomActions1");
return ActionResult.Success;
}
Product.Wix.Setup (referenced to Product.Wix.CustomActions project). In Setup.wxs, I have declared a custom action:
<Binary Id="CustomActions" SourceFile="..\Product.Wix.CustomActions\bin\Debug\Product.Wix.CustomActions.CA.dll" />
<CustomAction Id='Action1' BinaryKey='CustomActions' DllEntry='CustomAction1' Execute='immediate' Return='check' />
I have a custom dialog with Connect button and wiring to the action as below:
<Control Id="Connect" Type="PushButton" X="325" Y="75" Width="30" Height="17" Text="...">
<Publish Event="DoAction" Value="Action1">1</Publish>
</Control>
It does not work as I expected it should pop-up a message box when clicking on the Connect button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定 MessageBox.Show() 是否有效。另外,最好使用 WIX 对话框,因为您可以捕获用户在弹出窗口中选择的选项。
示例
自定义操作
Am not sure whether MessageBox.Show() will work. Also its better to go with WIX dialogs as you can capture the option selected by user on the popup.
Example
Custom Action
日志文件显示我的自定义操作程序集无法正确加载。原因是我无意中
从配置文件中 删除了以下部分:将其添加回来,现在一切正常。
The log file shows my custom action assemblies could not be loaded properly. The reason is I have unintentionally removed the section:
from the config file. Added it back and everything works now.