本文介绍了如何将自定义操作链接到控制事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Wix以构建产品安装程序。我已经成功地自定义了UI,但是想知道如何将自定义操作链接到控制事件(即PushButton)。

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).

我有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中,我声明了一个自定义操作:

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.

推荐答案

日志文件显示我的自定义操作程序集无法正确加载。原因是我无意中删除了以下部分:

The log file shows my custom action assemblies could not be loaded properly. The reason is I have unintentionally removed the section:

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" />
</startup>

从配置文件中。重新添加它,一切都可以正常工作。

from the config file. Added it back and everything works now.

这篇关于如何将自定义操作链接到控制事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 02:57