【问题标题】:WiX Custom Action Ends PrematurelyWiX 自定义操作提前结束
【发布时间】:2015-02-06 09:08:18
【问题描述】:

关于该主题有多个问题,我尝试了所有解决方案,但对我没有任何帮助。

问题是它“确实”在安装了 Visual Studio 的机器上工作,但在其他电脑上却不能工作。这使得调试变得非常困难。

自定义动作代码为:

[CustomAction]
public static ActionResult EnumerateSqlServers(Session session)
{
    MessageBox.Show("start EnumerateSQLServers"); // the message is not showing.
    ActionResult result;
    DataTable dt = SmoApplication.EnumAvailableSqlServers(false);
    DataRow[] rows = dt.Select(string.Empty);//, "IsLocal desc, Name asc");
    result = EnumSqlServersIntoComboBox(session, rows);
    return result;
}

日志文件显示:

MSI (c) (2C:1C) [11:16:42:338]: Doing action: EnumerateSqlServersAction
Action 11:16:42: EnumerateSqlServersAction. 
Action start 11:16:42: EnumerateSqlServersAction.
MSI (c) (2C:34) [11:16:42:385]: Invoking remote custom action. DLL: C:\Users\Test\AppData\Local\Temp\MSI9328.tmp, Entrypoint: EnumerateSqlServers
MSI (c) (2C:E8) [11:16:42:385]: Cloaking enabled.
MSI (c) (2C:E8) [11:16:42:385]: Attempting to enable all disabled privileges before calling Install on Server
MSI (c) (2C:E8) [11:16:42:385]: Connected to service for CA interface.
Action ended 11:16:42: EnumerateSqlServersAction. Return value 3.
DEBUG: Error 2896:  Executing action EnumerateSqlServersAction failed.
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2896. The arguments are: EnumerateSqlServersAction, , 
Action ended 11:16:42: WelcomeDlg. Return value 3.
MSI (c) (2C:44) [11:16:42:635]: Doing action: FatalError
Action 11:16:42: FatalError. 
Action start 11:16:42: FatalError.
Action 11:16:42: FatalError. Dialog created
Action ended 11:16:43: FatalError. Return value 2.
Action ended 11:16:43: INSTALL. Return value 3.
MSI (c) (2C:44) [11:16:43:370]: Destroying RemoteAPI object.
MSI (c) (2C:E8) [11:16:43:385]: Custom Action Manager thread ending.

我确实尝试过这样的空操作:

 [CustomAction]
        public static ActionResult CustomAction1(Session session)
        {
            MessageBox.Show("");
            return ActionResult.Success;
        }

该操作有效!它显示一个空的消息框。

编辑:经过大量测试,当我评论此行时,我发现问题出在 enumSQLServer 上。

SmoApplication.EnumAvailableSqlServers(false);

【问题讨论】:

    标签: c# wix custom-action wix3.8


    【解决方案1】:

    使用详细 (/l*v) 设置记录安装程序。我希望看到更多,包括 .NET 错误堆栈跟踪。您可能错过了 Visual Studio 机器上的依赖项,而不是您干净的测试机器上的依赖项。

    最有可能缺少的依赖项是 Microsoft.SqlServer.Smo.dll。在您的自定义操作项目中检查此引用是否设置为 CopyLocal = true,如果不是,请设置它。

    【讨论】:

    • 谢谢你的日志设置,我试试看。
    • 您会发现 EnumAvailableSqlServers 正在抛出错误。您也可以将它放在 try catch 块中并记录或显示错误。
    • 问题是相同的代码,在一个独立的 exe 中,工作得很好。在自定义操作中,它在进入该子之前崩溃,早在该行之前。
    • 嗯,我以前从未听说过“在我的 EXE 中工作”这一行。 :)
    • 调用静态方法的 DTF 代码将所有内容包装在它自己的 try catch 中并将其记录到 MSI。做一个详细的日志并查看结果。
    【解决方案2】:

    您是否已经尝试使用提升的权限运行设置(右键单击设置并选择“以管理员身份运行”)?

    据我所知,SmoApplication.EnumAvailableSqlServers(false) 需要提升权限。

    同时检查您在 .wxs 文件中 Product 节点中自定义操作的定义。

    以下定义应该有效:

    <CustomAction Id="EnumerateSqlServers" BinaryKey="YOUR BINARY KEY" DllEntry="EnumerateSqlServers" Execute="immediate" Return="check"/>

    还可以尝试以下方法进行测试:

    <InstallUISequence> <Custom Action="EnumerateSqlServers" Before="ExecuteAction" Overridable="yes">NOT Installed</Custom> </InstallUISequence>

    【讨论】:

    • 始终使用提升的权限完成设置。我会检查其他建议。谢谢
    【解决方案3】:

    就我而言,这是在安装和卸载时发生的。

    我们正在做的是加密作为参数传入的连接字符串。

    安装

    这失败了,因为我无权访问我们仍在处理的已安装配置文件。 我希望 WiX 更易于使用或有更好的文档。

    卸载

    因为我们对自定义操作没有任何条件,所以它在卸载过程中也在运行,并且在尝试加载不再存在的配置文件时失败。

    解决方案:使用NOT Installed AND NOT REMOVEHow to execute custom action only in install (not uninstall)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多