Dafna Dafna - 2 months ago 16
C# Question

Wix installer: Error when tring to run a custom action from a button click - A DLL required for this install to complete could not be run

I am running a custom action and getting the following error message:

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 CheckLicenseFileExistsCA, entry: CheckLicenseFileExists, library: C:\Users\dafna\AppData\Local\Temp\MSI3395.tmp
MSI (c) (E8:04) [19:42:28:921]: Product: ReSecServer -- 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 CheckLicenseFileExistsCA, entry: CheckLicenseFileExists, library: C:\Users\dafna\AppData\Local\Temp\MSI3395.tmp

I tried to search google for the solution but nothing did the trick, I am probably missing something...

public class CutomActions
{
[CustomAction]
public static ActionResult CheckLicenseFileExists(Session session)
{
try
{
var filename = Path.Combine(session["LICENSEFILE_DIR_PATH"], "license.dat");

var exists = File.Exists(filename);
if (exists)
{
session["LICENSE_FILE_PATH_VALID"] = "1";
}
}
catch (Exception ex)
{
return ActionResult.Failure;
}

return ActionResult.Success;
}

Here are the relevant lines:

<CustomAction Id='CheckLicenseFileExistsCA' BinaryKey='ServerInstallerCustomActions.CA' DllEntry='CheckLicenseFileExists' Execute="immediate" Return="check" /> <Binary Id='ServerInstallerCustomActions.CA' SourceFile='$(var.ServerInstallerCustomActions.TargetDir)\ServerInstallerCustomActions.dll' />


<Control Type="PushButton" Id="BrowseLicense" Width="75" Height="17" X="251" Y="101" Text="{\VSI_MS_Sans_Serif13.0_0_0}Browse" TabSkip="no">
<Publish Property="_BrowseProperty" Value="LICENSEFILE_DIR_PATH" Order="1">1</Publish>
<Publish Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
<Publish Event="DoAction" Value="CheckLicenseFileExistsCA">1</Publish>
<Publish Property="TEMP_VERIFIED" Value="[LICENSE_FILE_PATH_VALID]">1</Publish>
<Publish Property="LICENSE_FILE_PATH_VALID" Value="[TEMP_VERIFIED]" />
</Control>


There also a config file (in the custom action project):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="false">
<supportedRuntime version="v4.0" />
</startup>
</configuration>

Answer

When you build your custom action project, there should be a post build event run that runs "MakeSfxCA.exe" which outputs <ProjectTargetName>.CA.dll <-- this is what you want to include with the binary tag, not the dll output from the Custom Action project

so you should be using:

<Binary Id='ServerInstallerCustomActions.CA' SourceFile='$(var.ServerInstallerCustomActions.TargetDir)\ServerInstallerCustomActions.CA.dll' />