1

I have an app that I programmed in C# with Visual Studio 2017 that use Microsoft.ACE.OLEDB.12.0 to make querys and return some data.

Now that I published, for other PC's that doesn't have Microsoft.ACE.OLEDB.12.0 installed, the app returns some error and it doesn't execute the tasks correctly.

There is a way to include this Microsoft.ACE.OLEDB.12.0 in my installer, or other ways to correct this?

PS.: I have Microsoft Office Access database engine 2007 installed in my machine to use the app with Microsoft.ACE.OLEDB.12.0 . I dont know if I have to install in other machines too, or how to do it with my installer.

I was searching about adding a reference or dll that solves the problem. But I didn't found anything yet.

Thanks for now!

Talisson47
  • 11
  • 4

1 Answers1

1

Create custom bootstrapper packages

First, You should create a new folder named AccessEngineDatabase, then download and copy the Microsoft Access Database Engine 2016 Redistributable files you downloaded into the folder you created.

Next, Create a product.xml file as shown below.

<?xml version="1.0" encoding="utf-8" ?> 
 <Product 
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" 
  ProductCode="Access.Database.Engine.2016" 
 > 
  <!-- Defines list of files to be copied on build --> 
  <PackageFiles CopyAllPackageFiles="true"> 
   <PackageFile Name="AccessDatabaseEngine.exe" HomeSite="https://download.microsoft.com/download/3/5/C/35C84C36-661A-44E6-9324-8786B8DBE231/AccessDatabaseEngine.exe" /> 
   <PackageFile Name="AccessDatabaseEngine_x64.exe" HomeSite="https://download.microsoft.com/download/3/5/C/35C84C36-661A-44E6-9324-8786B8DBE231/AccessDatabaseEngine_X64.exe" />
  </PackageFiles> 
  <RelatedProducts> 
   <DependsOnProduct Code="Microsoft.Net.Framework.2.0" />
  </RelatedProducts> 
  <InstallChecks> 
       <MsiProductCheck Property="IsInstalled"  
         Product="{90160000-00D1-0409-1000-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>

You can easily find the product code in your registry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

If you want to add a PublicKey to the PackageFile you can find your PublicKey as shown below.

Right-clicking on setup file, then select Properties

find public key of setup

Select Digital Signatures tab, then click the Details button.

digital signature details

Clicking the View Certificate button.

view cert

Select the Details tab, then you can see the public key.

Finally, create a new directory named en, then create a package.xml file as shown below.

<?xml version="1.0" encoding="utf-8" ?>  
 <Package 
  xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" 
  Name="DisplayName" 
  Culture="Culture"> 
  <!-- Defines a localizable string table for error messages and url's --> 
  <Strings> 
   <String Name="DisplayName">Microsoft Access Database Engine 2016</String> 
   <String Name="Culture">en</String> 
   <String Name="DotNetFxRequired">Installation of Microsoft Access Database Engine 2016 requires Microsoft .NET Framework 2.0. Contact your application vendor.</String> 
   <String Name="InvalidPlatformWin9x">Installation of Microsoft Access Database Engine 2016 is not supported on Windows 95. Contact your application vendor.</String> 
   <String Name="InvalidPlatformWinNT">Installation of Microsoft Access Database Engine 2016 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 2016.</String> 
   <String Name="AdminRequired">You do not have the permissions required to install this application. Please contact your administrator.</String>
  </Strings> 
 </Package>

Folder should look like this: folderview

You need to Copy the original directory to C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages if you are using 64 bit windows or C:\Program Files\Microsoft SDKs\ClickOnce Bootstrapper\Packages

Right-clicking on your setup project, then select Properties.

setup

Clicking the Prerequisites button, then you can see your custom bootstrapper automatically added to the prerequisites dialogbox.

prerequisites

Select all prerequisites, then click OK button and rebuild your project.

SOURCE: https://foxlearn.com/articles/adding-custom-prerequisites-to-visual-studio-setup-project-468.html

HackSlash
  • 4,944
  • 2
  • 18
  • 44