c# - Wix 安装程序 : Error when tring to run a custom action from a button click - A DLL required for this install to complete could not be run

标签 c# wix windows-installer custom-action

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

错误 1723。此 Windows 安装程序包有问题。无法运行此安装完成所需的 DLL。请联系您的支持人员或软件包供应商。操作 CheckLicenseFileExistsCA,条目:CheckLicenseFileExists,库:C:\Users\dafna\AppData\Local\Temp\MSI3395.tmp MSI (c) (E8:04) [19:42:28:921]:产品:ReSecServer -- 错误 1723。此 Windows 安装程序包存在问题。无法运行此安装完成所需的 DLL。请联系您的支持人员或软件包供应商。操作 CheckLicenseFileExistsCA,条目:CheckLicenseFileExists,库: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>

最佳答案

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

所以你应该使用:

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

要获取 *CA.dll,您必须使用与 WiX 工具集相关的适当 Visual Studio 模板创建您的自定义操作项目,而不仅仅是通用类库。

关于c# - Wix 安装程序 : Error when tring to run a custom action from a button click - A DLL required for this install to complete could not be run,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38980579/

相关文章:

c# - 如何使用从数据库派生的相对文件路径将 WPF 图像元素绑定(bind)到本地硬盘驱动器上的 PNG?

database - WiX:数据库卸载

windows - Wix 安装程序根据用户输入创建注册表项

c# - 如何取消和回滚 VS2010 Windows Installer 中的自定义操作?

windows-installer - 将NSIS脚本构建为MSI软件包

c# - C# .Net 4.0 中的 Com 端口

c# - 在重载方法中使用泛型

c# - TableAdapter 做奔腾数学

Wix 3.5 - 更改/修复不要求提升

.net - 在延迟的自定义操作之间传递数据