简体   繁体   English

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

[英]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.错误 1723。此 Windows 安装程序包有问题。 A DLL required for this install to complete could not be run.无法运行此安装完成所需的 DLL。 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.操作 CheckLicenseFileExistsCA,条目:CheckLicenseFileExists,库:C:\\Users\\dafna\\AppData\\Local\\Temp\\MSI3395.tmp MSI (c) (E8:04) [19:42:28:921]:产品:ReSecServer -- 错误1723. 此 Windows Installer 程序包有问题。 A DLL required for this install to complete could not be run.无法运行此安装完成所需的 DLL。 Contact your support personnel or package vendor.请联系您的支持人员或软件包供应商。 Action CheckLicenseFileExistsCA, entry: CheckLicenseFileExists, library: C:\\Users\\dafna\\AppData\\Local\\Temp\\MSI3395.tmp操作 CheckLicenseFileExistsCA,条目:CheckLicenseFileExists,库: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>

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当您构建自定义操作项目时,应该有一个运行“MakeSfxCA.exe”的构建后事件运行,它输出<ProjectTargetName>.CA.dll <--这是您想要包含在二进制标记中的内容,而不是 dll自定义操作项目的输出

so you should be using:所以你应该使用:

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

To get the *CA.dll you'll have to create your custom action project using the appropriate Visual Studio template related to WiX Toolset, not just a generic Class Library.要获取 *CA.dll,您必须使用与 WiX 工具集相关的适当 Visual Studio 模板创建自定义操作项目,而不仅仅是通用类库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM