Wix C#Custom Action根本不执行
作者:互联网
我有一个安装程序,它有一个包含按钮的自定义屏幕.按下该按钮时,必须运行自定义操作,以验证一些事情,并返回成功或错误.
我的按钮定义如下:
<Control Type="PushButton" Id="DatabaseVerifyConnectionButton" X="118" Y="150" Width="116" Height="17" Text="Verify Connection" Property="DATABASEVERIFYCONNECTIONBUTTONPROPERTY" Default="yes">
<Publish Event="DoAction" Value="VerifyDatabaseConnection">1</Publish>
<Publish Event="SpawnDialog" Value="VerifySuccessDlg">VERIFIEDCONNECTION = "1"</Publish>
<Publish Event="SpawnDialog" Value="VerifyFailedDlg">VERIFIEDCONNECTION = "0"</Publish>
</Control>
我的自定义操作XML
<CustomAction Id="VerifyDatabaseConnectionCA"
BinaryKey="DatabaseCustomAction.CA.dll"
DllEntry="VerifyDatabaseConnection2"
Execute="immediate"
Return="check"/>
<CustomAction Id='VerifyDatabaseConnection'
Property='VerifyDatabaseConnectionCA'
Execute='immediate'
Value="ServerIP=[DATABASESERVERIPTEXTBOXPROPERTY];Username=[DATABASEUSERNAMETEXTBOXPROPERTY];Password=[DATABASEPASSWORDTEXTBOXPROPERTY]"/>
我的自定义操作C#代码:
[CustomAction]
public static ActionResult VerifyDatabaseConnection(Session session)
{
System.Diagnostics.Process.Start(@"C:\Windows\System32\calc.exe");
return ActionResult.Failure;
}
日志显示以下内容:
MSI (c) (58:B4) [16:39:45:183]: Doing action: VerifyDatabaseConnection
Action 16:39:45: VerifyDatabaseConnection.
Action start 16:39:45: VerifyDatabaseConnection.
Action ended 16:39:45: VerifyDatabaseConnection. Return value 1.
我尝试过很多东西.附加调试器不起作用.回归成功或失败,似乎并不重要.哎呀,单击按钮时它甚至没有启动计算器.我注意到更改自定义操作的入口点似乎根本不重要.
我还阅读了一些关于MakeSfxCA.exe的内容,但我无法在生活中找到任何关于如何使其正常工作的内容.但我还读到,如果您将自定义操作项目添加为自定义操作项目,Visual Studio应该为您执行此操作.
我在这里完全失败了.为什么这不起作用?它显示了无处不在的成功,但它根本不执行任何代码.
解决方法:
<CustomAction Id="VerifyDatabaseConnectionCA"
BinaryKey="DatabaseCustomAction.CA.dll"
DllEntry="VerifyDatabaseConnection2"
Execute="immediate"
Return="check"/>
检查DLLEntry名称“VerifyDatabaseConnection2”,但实际的自定义操作方法名称是“VerifyDatabaseConnection”(缺少2,因此永远不会被调用“).
同时更改publish元素以调用“VerifyDatabaseConnectionCA”而不是“VerifyDatabaseConnection”.
标签:c,wix,custom-action 来源: https://codeday.me/bug/20190708/1406343.html