Wix自定义操作运行dll c#

问题描述 投票:0回答:1

我正在使用自定义操作从dll运行功能,但是当我运行自己构建的msi时,出现错误:

“此Windows Installer软件包存在问题。无法运行完成此安装所需的DLL。请与您的支持联系...”

这是我做的:

       <Fragment>
<UI>
  <Dialog Id="UserRegistrationDlg" Width="370" Height="270" Title="[ProductName] [Setup]" NoMinimize="yes">

    <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
      <Publish Event="DoAction" Value="MyCustomAction">1</Publish>
      <Publish Event="SpawnWaitDialog" Value="WaitForCostingDlg">CostingComplete = 1</Publish>
      <Publish Event="NewDialog" Value="SetupTypeDlg">ProductID</Publish>
    </Control>
    <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
      <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish>
    </Control>
    <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
    <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
      <Text>Please enter your customer information</Text>
    </Control>
    <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
    <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
      <Text>{\WixUI_Font_Title}Customer Information</Text>
    </Control>
    <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />

  <Control Id="PlatformCombobox" Type="ComboBox" X="45" Y="127" Width="220" Height="18" ComboList="yes" Sorted="yes" Property="Platform">
    <ComboBox Property="Platform">
      <ListItem Value="1" Text="1"/>
      <ListItem Value="2" Text="2 "/>
      <ListItem Value="3" Text="3 "/>
      <ListItem Value="4" Text="4 "/>
    </ComboBox>
  </Control>
  </Dialog>
</UI>
    <Property Id="Platform" Value="2" />

    <CustomAction Id='MyCustomAction' BinaryKey='CreateFile' DllEntry='CreateFile'/>
    <Binary Id='CreateFile' SourceFile='SetupDll.dll'/>


  </Fragment>

您可以看到我正在尝试运行SetupDll.dll,其中包含具有1个函数的1个类:

using System.IO;
using Microsoft.Deployment.WindowsInstaller;

namespace SetupDll
{
    public class Creator
    {
        [CustomAction]
        public static ActionResult CreateFile(Session session)
        {
            File.WriteAllText(@"C:\a.txt", "123");
            return ActionResult.Success;
        }
    }
}

但是我不明白这个问题。我将生成的SetupDll.dll放置在wix项目的每个文件夹中。

谢谢!

我正在使用自定义操作从dll运行功能,但是当我运行自己构建的msi时,出现错误消息:“此Windows Installer软件包存在问题。此安装需要DLL。 。

c# visual-studio wix installer wix3
1个回答
0
投票

二进制元素应指向SetupDll.CA.dll,而不是SetupDll.dll。

© www.soinside.com 2019 - 2024. All rights reserved.