Question

I'm trying to create a custom action for my Wix install, and it's just not working, and I'm unsure why.

Here's the bit in the appropriate Wix File:

<Binary Id="INSTALLERHELPER" SourceFile=".\Lib\InstallerHelper.dll" />
<CustomAction Id="HelperAction" BinaryKey="INSTALLERHELPER" DllEntry="CustomAction1" Execute="immediate" />

Here's the full class file for my custom action:

using Microsoft.Deployment.WindowsInstaller;

namespace InstallerHelper
{
  public class CustomActions
  {
    [CustomAction]
    public static ActionResult CustomAction1(Session session)
    {
      session.Log("Begin CustomAction1");

      return ActionResult.Success;
    }
  }
}

The action is run by a button press in the UI (for now):

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

When I run the MSI, I get this error in the log:

MSI (c) (08:5C) [10:08:36:978]: Connected to service for CA interface.
MSI (c) (08:4C) [10:08:37:030]: Note: 1: 1723 2: SQLHelperAction 3: CustomAction1 4: C:\Users\NATHAN~1.TYL\AppData\Local\Temp\MSI684F.tmp 
Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor.  Action SQLHelperAction, entry: CustomAction1, library: C:\Users\NATHAN~1.TYL\AppData\Local\Temp\MSI684F.tmp 
MSI (c) (08:4C) [10:08:38:501]: Product: SessionWorks :: Judge Edition -- Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run. Contact your support personnel or package vendor.  Action SQLHelperAction, entry: CustomAction1, library: C:\Users\NATHAN~1.TYL\AppData\Local\Temp\MSI684F.tmp 

Action ended 10:08:38: SQLHelperAction. Return value 3.
DEBUG: Error 2896:  Executing action SQLHelperAction failed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: SQLHelperAction, , 

Neither of the two error codes or messages it gives me is enough to tell me what's wrong. Or perhaps I'm just not understanding what they're saying is wrong.

At first I thought it might be because I was using Wix 3.5, so just to be sure I tried using Wix 3.0, but I get the same error.

Any ideas on what I'm doing wrong?

Was it helpful?

Solution

For your custom action assembly you need a config file and set the useLegacyV2RuntimeActivationPolicy attribute to true. Make sure you name your config file CustomAction.config. If you don't, it won't work. I am assuming you are running on the .NET 4 Framework.

See here for more info. Also, as AntonyW already pointed out, fuslogvw.exe is very helpful in this scenario.

OTHER TIPS

instead of referencing the .dll reference the .CA.dll, it worked for me.

Custom Actions launched via DoAction are not able to write to the log file.

This confused me as well, when I first started using WiX.

If you want to see what is going on, you can use System.Diagnostics.Debugger.Launch() at the start of the Custom Action. This will prompt you to attach Visual Studio to the process so you can debug it.

This error comes when you have installer project configuration/platform set to debug/x64 and custom action project configuration/platform set to debug/x86 repectively.

Correct the platform setting to build the projects for same platform

In my case changing platorm solved the issue.

Thanks Yogesh

One more possible answer - you may have specified the right CA DLL, and specified the right method, but if the method is not decorated with [CustomAction] you will receive that error.

For me, it was my CustomAction DllEntry did not match my method name. i.e.

<CustomAction Id="CheckingPID" BinaryKey="CheckPID.CA" DllEntry="BadValue" />

public static ActionResult CheckPID(Session session)

Have you tried changing the runtime library settings on the custom action DLL? The debug mode options /MDd and /MtD require debug versions of the C++ runtime in particular, which are not available on production machines (there is no redistributable license for them). If you use the /MD compiler option you might also need to install the Visual Studio C++ runtime version that you require on the users' machines, there is a merge module for that: C++ Redistributable package with WIX.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top