tags:

views:

344

answers:

4

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?

A: 

The custom action name listed in the log file is 'SqlHelperAction', but I failed to find the same CA in your snippets... Are you referring this CA somewhere which really doesn't exist in the assembly?

Yan Sklyarenko
I had changed the name of the action from SQLHelperAction between posting the log and the code. I get the same thing, though. Thanks for the catch!
Grandpappy
A: 

Try running fuslogvw.exe and set it to log bind failures. You may just be missing a dependency.

AntonyW
A: 

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.

Bryan Batchelder
Yeah, stupid Windows Installer restraint.
Rob Mensching
However they can write to files on the target machine!
Peter M
A: 

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: http://stackoverflow.com/questions/3468964/wix-c-custom-action-net-4-error

Also, as AntonyW already pointed out, fuslogvw.exe is very helpful in this scenario.

KnightsArmy