代码之家  ›  专栏  ›  技术社区  ›  MikeBaz - MSFT

WIX 3.5.2030.0 CreateDatabase使用DTF外部UI处理程序失败,使用1603,不使用外部UI处理程序工作

  •  2
  • MikeBaz - MSFT  · 技术社区  · 15 年前

    我在Windows7上有一个简单的wix(3.5.2030.0)安装程序(根据msiexec.exe的属性,WindowsInstaller 5.0.7600.16385),它使用提供的自定义操作创建SQL数据库。当我自己运行MSI,或者在C安装引导程序的事务中运行它(使用DTF进行互操作)时,它工作正常。

    当我在引导程序中运行msi并挂接一个外部UI处理程序时(与工作的代码相比,唯一的代码更改是这样的调用:

    Installer.SetExternalUI(ExternalUIHandler, ilm);
    

    但是,createDatabase调用失败。在SQL日志中没有任何相关信息-它显示正在启动的数据库。在SQL事件探查器中没有相关的内容-它显示CA检查数据库是否存在,然后在创建失败后删除尝试。以下是调试详细日志显示的内容:

    MSI (s) (74:F4) [16:42:59:213]: Executing op: ActionStart(Name=CreateDatabase,Description=Creating Databases,)
    MSI (s) (74:F4) [16:42:59:243]: Executing op: CustomActionSchedule(Action=CreateDatabase,ActionType=25601,Source=BinaryData,Target=**********,CustomActionData=**********)
    MSI (s) (74:F4) [16:42:59:253]: Creating MSIHANDLE (769) of type 790536 for thread 5876
    MSI (s) (74:A4) [16:42:59:253]: Invoking remote custom action. DLL: C:\Windows\Installer\MSID856.tmp, Entrypoint: CreateDatabase
    MSI (s) (74!7C) [16:43:01:493]: Creating MSIHANDLE (770) of type 790531 for thread 8060
    MSI (s) (74!7C) [16:43:01:513]: Closing MSIHANDLE (770) of type 790531 for thread 8060
    CustomAction CreateDatabase returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)
    MSI (s) (74:A4) [16:43:14:682]: Closing MSIHANDLE (769) of type 790536 for thread 5876
    

    请注意,日志中没有显示有用的SQL错误代码——只是1603错误(翻译:有问题)。

    在外部UI处理程序中挂接与运行数据库创建有什么关系?

    我知道这个问题与我的外部UI处理程序代码有关,因为如果我用“return messageresult.none”将其短路,那么一切都会正常工作。

    我的顶级处理程序代码在下面;它基于 http://msdn.microsoft.com/en-us/library/aa368786(VS.85).aspx :

            switch (messageType) {
                case InstallMessage.FatalExit:
                    MessageBox.Show("FATAL EXIT: " + message, "Fatal exit",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                case InstallMessage.Error:
                    MessageBox.Show("ERROR: " + message, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                case InstallMessage.Warning:
                    MessageBox.Show("WARNING: " + message, "Warning",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                case InstallMessage.User:
                    // nothing to do here
                    break;
                case InstallMessage.Info:
                    // nothing to do here
                    break;
                case InstallMessage.FilesInUse:
                    MessageBox.Show("Files in use: " + message, "Files in use",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    break;
                case InstallMessage.ResolveSource:
                    // nothing to do here
                    break;
                case InstallMessage.OutOfDiskSpace:
                    MessageBox.Show("OUT OF DISK SPACE: " + message,
                                    "Out of disk space", MessageBoxButtons.OK,
                                    MessageBoxIcon.Exclamation);
                    break;
                case InstallMessage.ActionStart:
                    _enableActionData = false;
                    ProcessActionStart(message);
                    break;
                case InstallMessage.ActionData:
                    ProcessActionDataMessage(message);
                    break;
                case InstallMessage.Progress:
                    // http://msdn.microsoft.com/en-us/library/aa370573(VS.85).aspx
                    ProcessProgressData(message);
                    break;
                case InstallMessage.CommonData:
                    // ignore for now
                    break;
                case InstallMessage.Initialize:
                case InstallMessage.Terminate:
                    SetHighLevelStatus(messageType.ToString());
                    break;
                case InstallMessage.ShowDialog:
                    // nothing to do here
                    break;
            }
            AddDetailedStatusLine("... " + messageType + ":" + message);
            return MessageResult.None;
            //return MessageResult.OK;
    

    因为完整的UI还没有实现,现在只是进度部分,所以我返回“none”,这样内部的UI仍然会触发。显然,这需要在生产前进行更改。同样的情况也适用于MessageBox调用,生产代码中可能会对其进行不同的处理。

    谢谢!

    1 回复  |  直到 14 年前
        1
  •  1
  •   MikeBaz - MSFT    15 年前

    如果有其他人可能会遇到这种情况,结果发现我在代码中碰到了一个我没有处理的异常,所以它一直被传递到Windows Installer,它将异常视为失败并将其回滚。