在未安装Visual C++ 2005 的计算机上运行使用 Visual C++ 2005开发的应用程序,必须先安装Visual C++2005 运行时刻库组件。Visual C++ 2005 SP1更新了这个组件,所以使用Visual C++2005 SP1 开发的应用程序必须随程序发布Visual C++ 2005 SP1运行时刻库组件。但是Visual C++ 2005 SP1的一个BUG造成使用安装和部署项目进行部署的时候,安装程序可能安装原版的Visual C++2005 运行时刻库组件,而不是SP1版本,造成使用Visual C++2005 SP1 开发的应用程序启动失败。这个问题的原因是%Program Files%Microsoft Visual Studio8\SDK\v2.0\BootStrapper\Packages\vcredist_x86下面的product.xml中的产品代码在安装Visual C++ 2005 SP1的过程中没有更新。要修正这个问题,可以打开这个文件,修改如下两行
<MsiProductCheck Property="VCRedistInstalled" Product="{A49F249F-0C91-497F-86DF-B2585E8E76B7}"/>
和
<BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="3"/>
为
<MsiProductCheck Property="VCRedistInstalled" Product="{7299052b-02a4-4627-81f2-1818da5d550d}"/>
和
<BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="5"/>
改后的product.xml文件如下
<?xml version="1.0" encoding="utf-8" ?>
<Product
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="Microsoft.Visual.C++.10.0.x86"
>
<!-- Defines list of files to be copied on build -->
<PackageFiles>
<PackageFile Name="vcredist_x86.exe" HomeSite="VCRedistExe"/> <!--补丁-->
</PackageFiles>
<InstallChecks>
<MsiProductCheck Property="VCRedistInstalled" Product="{7299052b-02a4-4627-81f2-1818da5d550d}"/>
<!-- <MsiProductCheck Property="VCRedistInstalled" Product="{196BB40D-1578-3D01-B289-BEFC77A11A1E}"/> -->
</InstallChecks>
<!-- Defines how to invoke the setup for the Visual C++ 10.0 redist -->
<!-- TODO: Needs EstrimatedTempSpace, LogFile, and an update of EstimatedDiskSpace -->
<Commands Reboot="Defer">
<Command PackageFile="vcredist_x86.exe"
Arguments=' /q:a '
>
<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<!-- <BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="3"/>-->
<BypassIf Property="VCRedistInstalled" Compare="ValueGreaterThanOrEqualTo" Value="5"/>
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on Win95 -->
<FailIf Property="Version9X" Compare="VersionLessThan" Value="4.10" String="InvalidPlatformWin9x"/>
<!-- Block install on NT 4 or less -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.00" String="InvalidPlatformWinNT"/>
</InstallConditions>
<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>
</Product>
另外,Visual C++ 2005 SP1版本的可以用最新的Visual C++ 2005 SP1运行时刻库组件来替换%Program Files%Microsoft Visual Studio8\SDK\v2.0\BootStrapper\Packages\vcredist_x86下面的vcredist_x86.exe,这样安装和部署项目产生的安装程序中会包含最新版的组件。