开发者

How to link custom action to control event

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'开发者_如何学C />

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.


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

<Control Id="TestConn" Type="PushButton" X="265" Y="205" Width="70" Height="18" Text="&amp;Test Connection">
    <Publish Event="DoAction" Value="Action1">1</Publish>
    <Publish Property="ERRORMSG" Value="CustomActions1">ACCEPTED = "1"</Publish>
    <Publish Event="SpawnDialog" Value="InvalidDBConnDlg">ACCEPTED = "0"</Publish>
</Control>

<Dialog Id="InvalidDBConnDlg" Width="260" Height="120" Title="[ProductName]">
    <Control Id="OK" Type="PushButton" X="102" Y="90" Width="56" Height="17" Default="yes" Cancel="yes" Text="OK" />
    <Control Id="Text" Type="Text" X="48" Y="22" Width="194" Height="60" Text="[MSGVAR]" />
    <Control Id="Icon" Type="Icon" X="15" Y="15" Width="24" Height="24" ToolTip="Information icon" FixedSize="yes" IconSize="32" Text="WixUI_Ico_Info" />
</Dialog>

Custom Action

[CustomAction]
public static ActionResult CustomAction1(Session session)
{
    session["MSGVAR"] = "Some Message";
    return ActionResult.Success;
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜