9

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?

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
Nathan
  • 1,591
  • 4
  • 17
  • 22
  • 2
    "A DLL required for this install to complete could not be run." - this indicates that the installer found the dll but couldn't find a method in it. You mentioned that you changed the code after you posted the log - can you may be post an updated log? How did you run the log - did you do /l*vx option? – demp Jun 13 '12 at 15:39

7 Answers7

8

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

Kirka121
  • 505
  • 4
  • 13
  • Ah, finally, that was it for me as well. – laifukang Aug 01 '14 at 07:52
  • 2
    This is exactly what happened to me. I created a project named "Company.CA" which produced "Company.CA.dll". But then WiX stuffed everything into "Company.CA.CA.dll" and I didn't notice. I wasted a whole hour on it! – Rodolfo Neuber Mar 18 '15 at 01:33
8

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.

Community
  • 1
  • 1
KnightsArmy
  • 680
  • 1
  • 6
  • 12
7

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.

Yan Sklyarenko
  • 31,557
  • 24
  • 104
  • 139
Bryan Batchelder
  • 3,627
  • 21
  • 17
  • However they can write to files on the target machine! – Peter M Jul 16 '10 at 14:10
  • 3
    Debugger.Launch() didn't do anything for me. – Joel McBeth Dec 19 '12 at 16:08
  • 1
    @jcmcbeth by default, Windows 8 and up is configured to prevent the debugger to be launched in a different user session. To work around the issue one can remove the flag by running this in the command line: `reg add "HKCR\AppID\{E62A7A31-6025-408E-87F6-81AEB0DC9347}" /v AppIDFlags /t REG_DWORD /d 8 /f` to restore the default value, run this: `reg add "HKCR\AppID\{E62A7A31-6025-408E-87F6-81AEB0DC9347}" /v AppIDFlags /t REG_DWORD /d 40 /f` see [here](https://blogs.msdn.microsoft.com/dsvc/2012/12/30/jit-debugging-using-visual-studio-may-fail-when-trying-to-debug-a-session-0-process-on-windows-8/) – Tsahi Asher May 03 '17 at 09:59
1

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)
Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88
1

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

Yogesh B
  • 11
  • 1
1

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.

0

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.

Community
  • 1
  • 1