title: 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
body: <p>I am running a custom action and getting the following error message:</p>
  
  <p>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 </p>
  
  <p>I tried to search google for the solution but nothing did the trick, I am probably missing something...</p>
  
  <pre><code>    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:
  
  &lt;CustomAction Id='CheckLicenseFileExistsCA' BinaryKey='ServerInstallerCustomActions.CA' DllEntry='CheckLicenseFileExists' Execute="immediate" Return="check" /&gt; &lt;Binary Id='ServerInstallerCustomActions.CA' SourceFile='$(var.ServerInstallerCustomActions.TargetDir)\ServerInstallerCustomActions.dll' /&gt;
  
  
  &lt;Control Type="PushButton" Id="BrowseLicense" Width="75" Height="17" X="251" Y="101" Text="{\VSI_MS_Sans_Serif13.0_0_0}Browse" TabSkip="no"&gt;
        &lt;Publish Property="_BrowseProperty" Value="LICENSEFILE_DIR_PATH" Order="1"&gt;1&lt;/Publish&gt;
        &lt;Publish Event="SpawnDialog" Value="BrowseDlg" Order="2"&gt;1&lt;/Publish&gt;
        &lt;Publish Event="DoAction" Value="CheckLicenseFileExistsCA"&gt;1&lt;/Publish&gt;
        &lt;Publish Property="TEMP_VERIFIED" Value="[LICENSE_FILE_PATH_VALID]"&gt;1&lt;/Publish&gt;
        &lt;Publish Property="LICENSE_FILE_PATH_VALID" Value="[TEMP_VERIFIED]" /&gt;
      &lt;/Control&gt;
  </code></pre>
  
  <p>There also a config file (in the custom action project):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;startup useLegacyV2RuntimeActivationPolicy="false"&gt;
      &lt;supportedRuntime version="v4.0" /&gt;
    &lt;/startup&gt;
  &lt;/configuration&gt;
  </code></pre>