如何使用Windows Installer管理的自定义操作显示错误消息 [英] How do I show Error Message using Managed Custom Actions with Windows Installer

查看:452
本文介绍了如何使用Windows Installer管理的自定义操作显示错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个托管的自定义操作。我正在使用Windows Installer Xml的DTF框架将托管的DLL转换为可用的CA dll。 CA执行它应该是什么,但是我仍然遇到错误处理的麻烦:

 记录为新记录(1 )

'字段0有意留空
'字段1包含错误号
记录(1)= 27533
session.Message(InstallMessage.Error,record)

上述代码生成MSI日志中显示的以下文本:


MSI(c)(C4!C6)[13:15:08:749]:产品:TestMSI - 错误27533.区分大小写的密码不匹配。 / p>

错误编号是指包含在MSI中的Error表中的代码。我的问题是:为什么Windows Installer不会创建一个通知用户错误的对话框?



div class =h2_lin>解决方案

MSI可以做到这一点,但是您需要在某些额外的值中为messageType参数。



例如

 记录记录=新的Record(); 
record.FormatString = string.Format(Something has wrong wrong!);

session.Message(
InstallMessage.Error |(InstallMessage)(MessageBoxIcon.Error)|
(InstallMessage)MessageBoxButtons.OK,
record);

请参阅这个线程从wix-users邮件列表获取更多详细信息。


I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling:

Dim record As New Record(1)

' Field 0 intentionally left blank
' Field 1 contains error number
record(1) = 27533
session.Message(InstallMessage.Error, record)

The above code produces the following text shown in the MSI log:

MSI (c) (C4 ! C6) [13:15:08:749]: Product: TestMSI -- Error 27533. The case-sensitive passwords do not match.

The error number refers to the code contained in the Error table within the MSI. The Message shown above is correct.

My problem is: Why does Windows Installer NOT create a dialog notifying the user about the error?

解决方案

MSI can do this, but you need to OR in some extra values for the messageType argument.

eg.

Record record = new Record();
record.FormatString = string.Format("Something has gone wrong!");

session.Message(
    InstallMessage.Error | (InstallMessage) ( MessageBoxIcon.Error ) |
    (InstallMessage) MessageBoxButtons.OK,
    record );

See this thread from the wix-users mailing list for more details.

这篇关于如何使用Windows Installer管理的自定义操作显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆