0

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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Not the answer I was looking for, but its probably the best. I created a Wizard in the application, and then created a command line argument that fires it up first thing in that instance. I then called "program.exe /w True" as a Custom Action of the installer after Commit.
0

Have a look at How the Runtime Locates Assemblies

I would suggest following. At installation install the ODP.NET into the Global Assembly Cache (GAC), then you don't have to specify the DLL path at all.

However, by default the application will take the latest version from GAC. Have a look at How to load specific version of assembly from GAC to see how to load a specific version from GAC. Otherwise the application may load a newer version from GAC and connection will fail.

2 Comments

It appears that to load the correct version from the GAC you have to add <publisherPolicy apply="no" /> to the app.config. But considering that the Install program can't read the application's app.config, how would I tell the msi to not apply the publsher policy?
I would say, it is not the duty of the installer to read the app.config file - it would be more the task to create this file. And for this, all content should be known.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.