【发布时间】:2020-07-05 12:34:17
【问题描述】:
我正在使用自定义操作从 dll 运行一个函数,但是当我运行我构建的 msi 时,我得到了错误:
“此 Windows 安装程序包存在问题。无法运行完成此安装所需的 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="&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 项目的每个文件夹中..
谢谢!
【问题讨论】:
-
现在没时间回答,但是除非您具有提升的权限,否则写入操作将失败 - 如果您将其插入 GUI 序列或安装序列过早或过晚,则不会出现这种情况.尝试显示一个消息框,以确保您有自定义操作的“心跳”。你能在 github.com 上找到很多项目吗?
-
你能给我一个这样的项目的链接吗?我对此很陌生。谢谢
标签: c# visual-studio wix installation wix3