c# - 如何自定义 MSI 安装程序中的错误屏幕?

标签 c# .net visual-studio-2008 windows-installer

在 VS 2008 安装/部署项目中,有没有办法添加一个自定义错误对话框(或自定义现有的)来处理安装过程中遇到的错误?

最佳答案

如果我理解正确的话:

并非完全针对您的软件,但您可以针对软件的先决条件处理错误,这些错误在大多数情况下都会导致错误。您必须先转到必备程序包文件的位置。通常,这将是“C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\”。找到你的包文件夹,进入,有一个名为“en”的文件夹,里面有一个名为“package.xml”的xml文件。用文本编辑器打开它,你会看到:

    <InstallChecks>
    <RegistryCheck Property="DotNet35SP" Key="HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5" Value="SP" />
</InstallChecks>

<!-- Defines how to invoke the setup for .NET Framework redist -->
<Commands Reboot="Defer">
    <Command PackageFile="dotNetFx35setup.exe" 
         Arguments=' /lang:enu /passive /norestart' 
         EstimatedInstalledBytes="30000000" 
         EstimatedTempBytes="30000000">

        <!-- These checks determine whether the package is to be installed -->
        <InstallConditions>
            <!-- This indicates .NET Framework is already installed -->
            <BypassIf Property="DotNet35SP" Compare="ValueGreaterThanOrEqualTo" Value="1"/>

            <!-- Block install if user does not have admin privileges -->
            <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
            <!-- Block install on less than Windows XP SP2 -->
            <FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2" String="InvalidPlatformWinNT"/>

            <!-- Block install on W2K3 with no service pack -->
            <FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.0" String="InvalidPlatformWinNT"/>

            <!-- Block install if the platform is IA-64 -->
            <FailIf Property="ProcessorArchitecture" Compare="ValueEqualTo" Value="IA64" String="InvalidPlatformArchitecture" />
        </InstallConditions>

        <ExitCodes>
            <ExitCode Value="0" Result="Success"/>
            <ExitCode Value="1602" Result="Fail" String="UserCancelled"/>
            <ExitCode Value="1603" Result="Fail" String="GeneralFailure"/>
            <ExitCode Value="3010" Result="SuccessReboot"/>
            <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
        </ExitCodes>

    </Command>
</Commands>

<!-- Defines a localizable string table for error messages-->
<Strings>
    <String Name="DisplayName">.NET Framework 3.5 SP1</String>
    <String Name="Culture">en</String>
    <String Name="AdminRequired">Administrator permissions are required to install .NET Framework 3.5 SP1. Contact your administrator.</String>
    <String Name="InvalidPlatformWinNT">Installation of the .NET Framework 3.5 SP1 requires Windows XP SP2, Windows 2003 SP1, Windows Vista, or later. Contact your application vendor.</String>
    <String Name="InvalidPlatformArchitecture">This version of the .NET Framework 3.5 SP1 is not supported on an IA-64 operating system. Contact your application vendor.</String>
    <String Name="UserCancelled">The user has cancelled the installation. .NET Framework 3.5 SP1 has not been installed.</String>
    <String Name="GeneralFailure">A failure occurred attempting to install .NET Framework 3.5 SP1.</String>
    <String Name="DotNetFX35SP1Exe">http://go.microsoft.com/fwlink/?linkid=118076</String>
</Strings>

在“InstallConditions”标签之间,您可以添加/删除先决条件安装条件。然后在“strings”标签之间,您可以自定义错误消息。

更多信息:http://msdn.microsoft.com/en-us/library/ms229223.aspx

关于c# - 如何自定义 MSI 安装程序中的错误屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2725186/

相关文章:

c# - 使用 Dapper 获取 UTC 日期时间

java - 使用 java 通过 TransportWithMessageCredentials (UserName) 访问 WCF 服务

.net - Visual Studio 引用和版本控制 - 它是如何工作的?

visual-studio - 托管代码中 Visual Studio 的自定义调试引擎

c# - 错误请求 : QUERY_ID_INVALID telegram bot api

c# - 如何让垃圾收集器在集合超出范围之前处理该集合?

c# - 使用 clickonce 安全性发布 c# 应用程序会引发 osversion 错误的无效值

c# - 自适应卡片 C# - 如何在 Body ColumnSet(每行)中添加 Action.Submit

visual-studio-2008 - Visual Studio 2008 崩溃日志在哪里?

c# - 捕捉错误