Sean Anderson
Sean Anderson

Reputation: 789

Using Oracle.DataAccess.DLL already on PC, not providing it

I am looking to make my program more dynamic. I would like it to be able to support an Oracle 10g and an Oracle 11g database with the same program. If I build the program using the .DLL reference for one version then the other fails. Is there a way to use the Oracle.DataAccess.DLL that is already on the computer being installed upon, instead of providing the DLL in my installer?

Thanks in advance.

Upvotes: 3

Views: 6615

Answers (3)

Matthew Rodatus
Matthew Rodatus

Reputation: 1451

SpecificVersion is an attribute that applies only during build time. It was designed to assist if there are multiple versions of an assembly in the build environment; when SpecificVersion is true, it will ensure that you build against and reference the desired version. Once the target assembly is built, however, its references contain the strong name and the version number of the referenced assembly. So, if SpecificVersion is false, it's going to be set to reference whatever was the available version of the reference in the build environment at the time.

"Note that the Specific Version property is only a build-time directive, and it has no effect on the runtime version resolution of the referenced assembly" (http://www.code-magazine.com/article.aspx?quickid=0507041&page=3).

However, you could use version redirection to explicitly annotate that you accept any version. The oldVersion field specifies anything (the version you built against), and the newVersion attribute would specify which one you want to actually link against at runtime.

  <dependentAssembly>
    <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/>
    <bindingRedirect oldVersion="1.0.0.0-2.111.9999.9999" newVersion="2.102.2.20"/>
  </dependentAssembly>

(See http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx.)

That dependentAssembly node can be applied to different contexts. One possible context would be in a web.config or app.config as a child of the configuration/runtime/assemblyBinding node.

To answer your particular scenario of supporting both Oracle 10g and 11g? There are two options, the former of which was suggested by the user @BQ:

  1. Deploy only one version of ODP.NET. You should be able to talk to both versions of the database server (10g and 11g) from either version of ODP.NET (10g or 11g). See @BQ's answer below.
  2. If you really need to be able to link to two different assembly versions, you will need to have two different version redirection configurations. In other words, you'd need two app.config files, one of which contains a version redirection to the 10g ODP.NET version and the other to the 11g ODP.NET version.

A few more tips:

  1. Make sure you remove any Oracle-provided publisher policies from the GAC. These take precedence over ones in web/app.config
  2. By default, binding failures are cached, so if the ODP.NET assembly happened to fail binding with the version redirection, you'll need to restart IIS to purge the cached failures.

Upvotes: 6

BQ.
BQ.

Reputation: 9413

See @MattRodatus' excellent answer about using a binding redirect if you need to get your application to support multiple versions of Oracle.DataAccess that might be on a machine you're deploying to.

However, you should be able to access a 10g or an 11g database with either version of the Oracle client installation.

See the @the.jxc's answer at Oracle: Does a 10g oracle client work with an 11g server? for a good synopsis of which clients support which databases.

Upvotes: 1

CodingGorilla
CodingGorilla

Reputation: 19842

If you select the reference in Visual Studio and go to the Properties window (F4 by default), you'll see an option labeled "Specific Version". If you set this to false, the project will accept different versions of the DLL.

Now this doesn't necessarily mean that the project will find the version of the DLL. If it isn't near the .exe (i.e. in the folder, or subfolder) or in the GAC, then you'll have to do some work on your own to load it.

Upvotes: 2

Related Questions