WiXPackage icon indicating copy to clipboard operation
WiXPackage copied to clipboard

安装失败会直接跳到安装完成的画面,相当于没有安装错误的提示

Open nocanstillbb opened this issue 3 years ago • 3 comments

RT , 由于我改动比较大, 之后也不会提pr

nocanstillbb avatar Sep 21 '21 04:09 nocanstillbb

using System.ComponentModel;
        protected void ApplyComplete(object sender, ApplyCompleteEventArgs e)
        {
            this.BootstrapperModel.FinalResult = e.Status;
            string errorMessage = new Win32Exception(e.Status).Message;
            if (e.Status == 0)
            {
                installViewModel.State = InstallState.Applied;
            }
            else
            {
                installViewModel.State = InstallState.Failed;
            }

        }

ApplyComplete 里 可以用new Win32Exception(e.Status).Message 把错误码转换为错误文本

nocanstillbb avatar Sep 21 '21 04:09 nocanstillbb

好久没有看这部分代码了,最近看了一下,之前安装失败的错误信息确实没有暴露出来,确实可以像你所说的在下面这个方法里加一些异常消息的展示。 https://github.com/DG-Wangtao/WiXPackage/blob/64d47570d1b2ebe4fdad47b93f703624355c23f4/CustomBA/ViewModels/ProgressPageViewModel.cs#L124-L128

但我觉得没必要用Win32Exception这个方法,可以用这类中已经有的this.Message来展示这个异常信息。比如改为下面这样:

        protected void ApplyComplete(object sender, ApplyCompleteEventArgs e)
        {
            this.BootstrapperModel.FinalResult = e.Status;
            if (e.Status == 0)
            {
                installViewModel.State = InstallState.Applied;
            } else
            {
                 this.Message = e.Message;
                installViewModel.State = InstallState.Failed;
            }
        }

不过我这边没有vs的环境了不太好测试,所以暂时先不更新代码了,哪位如果遇到同样的问题的时候可以参考这个issue看一下。

DG-Wangtao avatar Jun 28 '22 17:06 DG-Wangtao

一般都有什么错误情况

Henxun avatar Jun 02 '23 06:06 Henxun