代码之家  ›  专栏  ›  技术社区  ›  KnightsArmy

使用wix c/.net 4自定义操作时出现错误2896

  •  11
  • KnightsArmy  · 技术社区  · 16 年前

    我尝试在Wix中使用我的第一个自定义操作,我得到:

    错误2896:执行操作CustomActionTest失败。

    我使用的是Visual Studio 2010、Wix 3.5、64位Windows 7 Ultimate、.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项目中使用了一个项目引用来定制操作。我不知道我做错了什么。

    2 回复  |  直到 13 年前
        1
  •  16
  •   Community Mohan Dere    9 年前

    我通过运行带有/lvx选项的msi来获得详细的日志记录来解决这个问题。我还必须将我的操作移到InstallExecuteSequence部分,以获取有意义的错误消息。当对CA的调用在按钮中时,没有返回任何有意义的消息。

    <InstallExecuteSequence>
        <Custom Action='CustomActionTest' After='InstallFinalize' />
    </InstallExecuteSequence>
    

    System.BadImageFormatException:无法加载文件或程序集“判断条件”或其依赖项之一。此程序集是由比当前加载的运行时更新的运行时生成的,无法加载。

    我将useLegacyV2RuntimeActivationPolicy属性更改为true。一切都开始顺利进行。

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

    这些链接帮助我提高了速度:

        2
  •  4
  •   Community Mohan Dere    9 年前

    作为推论 KnightsArmy 的回答此错误也会在 DLILATECT 属性 定制 元素错误。在我的例子中,我有一个打字错误,唯一能从日志中得到的错误信息是臭名昭著的错误2896。

    推荐文章