如何在未安装Office 2010的计算机上安装带有MS Access数据库的Visual Studio 2010设置项目?

3
我正在使用C#开发WPF应用程序。我已经在Visual Studio 2010中为WPF应用程序成功创建了安装项目。我使用MS Access 2010作为数据库。它可以在所有计算机上顺利安装。但是,在某些计算机上没有安装Microsoft Office,而在一些计算机上则安装了较低版本的MS Office,例如MS Office 2003。当我在这些计算机上安装我的应用程序时,会出现连接问题。请问我需要做什么?我需要在Visual Studio 2010的安装项目中包含任何MS Access 2010的先决条件吗?如果需要,它们都是哪些以及如何包含?
2个回答

5
我遇到了同样的问题,但我已经创建了一个 Microsoft Access Database Engine 2010 的引导程序包。我还在这个包中包含了它的 x64 版本,所以它应该也适用于 64 位机器。要包含任何先决条件,您必须添加一个相应的引导程序包。之后,您可以在先决条件列表中找到它。我想您已经知道了这一点。要构建引导程序,您需要两个清单 XML 文件。一个是 product.xml,另一个是 package.xml。下面我将写出所有的 XML 脚本。
产品 XML:
<Product
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
  ProductCode="Access.Database.Engine.2010"
>
  <!-- Defines list of files to be copied on build -->
  <PackageFiles CopyAllPackageFiles="false">
    <PackageFile Name="AccessDatabaseEngine.exe" HomeSite="http://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine.exe" />
    <PackageFile Name="AccessDatabaseEngine_x64.exe" HomeSite="http://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_x64.exe" />
  </PackageFiles>

  <RelatedProducts>
    <DependsOnProduct Code="Microsoft.Net.Framework.2.0" />
  </RelatedProducts>

  <InstallChecks>
            <MsiProductCheck Property="IsInstalled" 
                Product="{90140000-00D1-0409-0000-0000000FF1CE}"/>
  </InstallChecks>

  <Commands>
    <Command PackageFile="AccessDatabaseEngine.exe"
         Arguments='/passive'>

      <!-- These checks determine whether the package is to be installed -->

      <InstallConditions>
        <!-- ByPass if the Processor is not x86 -->
        <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="Intel"/>

    <!-- ByPass if we have installed -->
        <BypassIf Property="IsInstalled" Compare="ValueGreaterThan" Value="0" />

        <!-- 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="1641" Result="SuccessReboot"/>
        <ExitCode Value="3010" Result="SuccessReboot"/>
        <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
      </ExitCodes>
    </Command>

    <Command PackageFile="AccessDatabaseEngine_x64.exe"
         Arguments='/passive'>

      <!-- These checks determine whether the package is to be installed -->

      <InstallConditions>
        <!-- ByPass if the Processor is not x64 -->
        <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="AMD64"/>

    <!-- ByPass if we have installed -->
        <BypassIf Property="IsInstalled" Compare="ValueGreaterThan" Value="0" />

        <!-- 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="1641" Result="SuccessReboot"/>
        <ExitCode Value="3010" Result="SuccessReboot"/>
        <DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
      </ExitCodes>
    </Command>

  </Commands>
</Product>

XML包:

<?xml version="1.0" encoding="utf-8" ?> 

<Package
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
  Name="DisplayName"
  Culture="Culture"
  LicenseAgreement="license.txt"
>

  <PackageFiles>
    <PackageFile Name="license.txt"/>
  </PackageFiles>

  <!-- Defines a localizable string table for error messages and url's  -->
  <Strings>
    <String Name="DisplayName">Microsoft Access database engine 2010 (x86, x64)</String>
    <String Name="Culture">en</String>
    <String Name="DotNetFxRequired">Installation of Microsoft Access database engine 2010 requires Microsoft .NET Framework 2.0. Contact your application vendor.</String>
    <String Name="InvalidPlatformWin9x">Installation of Microsoft Access database engine 2010 is not supported on Windows 95. Contact your application vendor.</String>
    <String Name="InvalidPlatformWinNT">Installation of Microsoft Access database engine 2010 is not supported on Windows NT 4.0. Contact your application vendor.</String>
    <String Name="GeneralFailure">A fatal error occurred during the installation of Microsoft Access database engine 2010.</String>
    <String Name="AdminRequired">You do not have the permissions required to install this application.  Please contact your administrator.</String>
  </Strings>

</Package>

license.txt

For detail please Log on http://www.microsoft.com/en-us/download/details.aspx?id=13255

注意:我已经在我的Windows 7 x86机器上进行了测试,并且它运行得非常完美。如果已经安装,它不会重新安装。我没有x64机器,所以我不知道它的产品代码是什么。但我敢肯定它也能工作。它还可以从网站下载此软件包,我已经测试过了。
如果您需要进一步的帮助或完整的引导程序包,请告诉我。
干杯。

4

2
请注意,如果您使用MS Access Database Engine 2010,则您的应用程序将无法在64位Windows上运行。虽然有一个64位版本的引擎(AccessDatabaseEngine_x64.exe),但除了为部署打包带来许多困难之外,它还要求系统上没有安装任何32位的MS Office产品,这是一个更大的问题。解决方法是使用32位版本的Access Database Engine 2010,并强制您的.NET应用程序以32位模式运行(例如通过在Configuration Manager中选择x86平台);或者更好地替换MS Access为更好的替代品。 - Masood Khaari
@Massood Khaari,这就是我所做的,使用MS Access数据库引擎2010的32位版本,并以32位模式(目标平台x86)运行应用程序。 - Jens Granlund
1
是的,谢谢。我只是想警告Shailesh和其他遇到类似问题的人,关于这种限制,因为一个应用程序可能有其他依赖项需要64位平台才能正常工作。 - Masood Khaari
是的,微软增加了64位版本。但它几乎没用!在尝试安装时,它会提示首先卸载所有32位Office产品,包括MS Office 2010套件。从部署的角度来看,这令人失望。 - Masood Khaari
1
好的,感谢提供信息。我在答案中添加了一条注释,建议读取您的评论。 - Jens Granlund
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接