错误2896使用WiX C#/.NET 4自定义操作

我试图在WiX中使用我的第一个自定义动作,我得到:

error 2896: Executing action CustomActionTest Failed.

我使用的是Visual Studio 2010,WiX 3.5,64位Windows 7旗舰版,.NET Framework 4.

以下是我认为的相关部分:

<Binary Id="JudgeEditionCA" SourceFile="..\JudgeEditionCA\bin\Debug\JudgeEdition.CA.dll" />
<CustomAction Id="CustomActionTest" BinaryKey="JudgeEditionCA" DllEntry="CustomActionOne" Execute="immediate"/>

<Control Id="Next" Type="PushButton" X="248" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" >
    <Publish Event="DoAction" Value="CustomActionTest">1</Publish>
    <Publish Event="DoAction" Value="InvalidClientDesc">CLIENT_DESC_VALID = "0"</Publish>
    <Publish Event="NewDialog" Value="VerifyReadyDlg">CLIENT_DESC_VALID = "1"</Publish>
</Control>

从行动:

namespace JudgeEditionCA
{
    public class CustomActions
    {
        [CustomAction]
        public static ActionResult CustomActionOne( Session session )
        {
            return ActionResult.Success;
        }
    }
}

并从配置文件自定义操作:

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

最后我在WiX项目中使用了一个项目引用来进行自定义操作.我不知道我在做错什么

解决方法

我通过使用/ lvx选项运行我的msi来获得详细的日志记录.我也不得不将我的操作移到InstallExecuteSequence部分以获得有意义的错误消息.当呼叫CA在PushButton没有任何有意义的返回.
<InstallExecuteSequence>
    <Custom Action='CustomActionTest' After='InstallFinalize' />
</InstallExecuteSequence>

System.BadImageFormatException:无法加载文件或程序集“JudgeEdition”或其依赖关系之一.此程序集由运行时间比当前加载的运行时更新而无法加载.

我将useLegacyV2RuntimeActivationPolicy属性更改为true.一切都开始好运

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

这些链接帮助我加快速度:

> What does ‘useLegacyV2RuntimeActivationPolicy’ do in the .NET 4 config?
> http://www.marklio.com/marklio/PermaLink,ecc34c3c-be44-4422-86b7-900900e451f9.aspx

相关文章

在要实现单例模式的类当中添加如下代码:实例化的时候:frmC...
1、如果制作圆角窗体,窗体先继承DOTNETBAR的:public parti...
根据网上资料,自己很粗略的实现了一个winform搜索提示,但是...
近期在做DSOFramer这个控件,打算自己弄一个自定义控件来封装...
今天玩了一把WMI,查询了一下电脑的硬件信息,感觉很多代码都...
最近在研究WinWordControl这个控件,因为上级要求在系统里,...