Wix安装程序:从按钮单击运行自定义操作时出错 - 无法运行此安装完成所需的DLL

时间:2016-08-16 16:59:42

标签: c# wix windows-installer custom-action

我正在运行自定义操作并收到以下错误消息:

错误1723.此Windows Installer程序包存在问题。无法运行此安装所需的DLL。请联系您的支持人员或包装供应商。 Action CheckLicenseFileExistsCA,entry:CheckLicenseFileExists,library:C:\ Users \ dafna \ AppData \ Local \ Temp \ MSI3395.tmp MSI(c)(E8:04)[19:42:28:921]:产品:ReSecServer - 错误1723.此Windows Installer程序包存在问题。无法运行此安装所需的DLL。请联系您的支持人员或包装供应商。 Action CheckLicenseFileExistsCA,entry:CheckLicenseFileExists,library:C:\ Users \ dafna \ AppData \ Local \ Temp \ MSI3395.tmp

我试图搜索谷歌搜索解决方案,但没有做任何事情,我可能错过了一些东西......

    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>

还有一个配置文件(在自定义操作项目中):

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

1 个答案:

答案 0 :(得分:3)

当您构建自定义操作项目时,应该有一个运行的后期构建事件运行&#34; MakeSfxCA.exe&#34;输出<ProjectTargetName>.CA.dll&lt; - 这是您想要包含二进制标记的内容,而不是自定义操作项目的dll输出

所以你应该使用:

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