Search code examples
oraclevb.netwinformsodp.netvisual-studio-setup-proje

Setting Oracle.DataAccess.Client DllPath for Windows Installer Project


I have a Windows Forms application that accesses a legacy Oracle 9 database. Therefore, I am including an Oracle 11.2.0.4 Oracle Instant Client as a subfolder of the application. In my application I have an app.config that include a section for oracle.dataaccess.client and then sets the DllPath to the subfolder:

<oracle.dataaccess.client>
    <settings>
        <add name="DllPath" value="C:\Program Files\MyCompany\MyApp\Oracle_Client_64Bit\bin" />
    </settings>
</oracle.dataaccess.client>

I also created a WindowsInstaller class within the application project, and created an overrides sub for OnAfterInstall.

I created a Windows Setup Project and then added Custom Action for OnAfterInstall. My code successfully is able to update DllPath value to the installation directory\oracle_client\bin

After this is complete (but still during setup) I want to open up a dialog form (saved in the application project) that allows the user to configure their database connection string. The form opens and is fine, but I want to test the DB connection string they have entered before saving it to the application's app.config.

But the setup program is executing during all of this, and so it can't utilize the DllPath in the application's app.config, and it errors out.

Is there a way to programmatically set the DllPath before creating the OracleConnection? Is there a way to create an app.config for the MSI to use that could contain that configuration information? Any other ideas for workarounds?


Solution

  • That’s really not going to work. Instead do that on startup and store the connection string in the user’s profile.