使用WiX在InstallInitialize之后的C#自定义操作

时间:2012-09-20 06:58:22

标签: c# wix custom-action

我创建了一个简单的C#自定义操作。

[CustomAction]
public static ActionResult MySimpleAction(Session session)
{
    MessageBox.Show("It works!");
    return ActionResult.Success;
}

<Binary Id="myAction" 
        SourceFile="MyApp.CA.dll"/>

<CustomAction Id="myActionId" 
              BinaryKey="myAction" 
              DllEntry="MySimpleAction" 
              Execute="deferred" 
              Return="check" />

<InstallExecuteSequence>
      <Custom Action="myActionId" 
              After="InstallInitialize">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>

我运行安装时遇到错误2762.

当我跑步时

<InstallExecuteSequence>
    <Custom Action="myActionId" 
            Before="InstallFinalize">CHECKBOXCOPYPROP=1</Custom>
</InstallExecuteSequence>

我没有收到错误。为什么我不能在InstallInitialize之后运行?怎么运行?

1 个答案:

答案 0 :(得分:1)

你必须写:

<CustomAction Id="myActionId" BinaryKey="myAction" DllEntry="MySimpleAction" Execute="immediate" Return="check" />

使用Execute="deferred"它将无效。

除此之外,在CusomAction.config中必须写入:

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