12

I am trying to use my first custom action in WiX and I get:

error 2896: Executing action CustomActionTest failed.

I am using Visual Studio 2010, WiX 3.5, 64-bit Windows 7 Ultimate, .NET Framework 4.

Here are what I think are the relevant sections:

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

From the action:

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

And the configuration file from the custom action:

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

And finally I have used a project reference in my WiX project to the custom action. I am not sure what I am doing wrong.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
KnightsArmy
  • 680
  • 1
  • 6
  • 12

3 Answers3

17

I figured it out by running my msi with the /lvx option to get a verbose logging. I also had to move my action to the InstallExecuteSequence section to get a meaningful error message. When the call to the CA was in the PushButton nothing meaningful was returned.

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

System.BadImageFormatException: Could not load file or assembly 'JudgeEdition' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

I changed the useLegacyV2RuntimeActivationPolicy attribute to true. Everything started working nicely.

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

These links helped get me up to speed:

Community
  • 1
  • 1
KnightsArmy
  • 680
  • 1
  • 6
  • 12
  • 2
    Can you please explain where you put this entries? If I understand correctly, this is normally something you would put in the app.config file? The CA is usually a DLL assembly, so where does this info go? – Magnus Johansson Dec 19 '10 at 12:16
  • 6
    @Magnus, this file goes in your custom actions assembly, and has to be named CustomAction.config – Dan Morphis May 02 '11 at 18:43
  • @future readers: make sure that the file CustomAction.config has its build action set to 'Content'. The default for config files ('None') will not work – Beemen May 26 '16 at 11:58
4

As a corollary to KnightsArmy's answer this error is also thrown when the DllEntry attribute on the CustomAction element is wrong. In my case I had a typo and the only error information I could get out of the log was the infamous error 2896.

Community
  • 1
  • 1
Tedford
  • 2,842
  • 2
  • 35
  • 45
0

I got the same error code but the root cause is because one of the Custom Action methods throws an exception. If you don't write try-catch and write meaningful error messages. The MSI log will just tell you the error#.

Cheers

myNameCoad
  • 2,583
  • 2
  • 12
  • 15