Our application is compiled with Oracle.Dataaccess.dll version 18.104.22.168 on the other hand the customers Oracle clients can be 10g or 11g and the GAC version of Oracle.Dataaccess.dll may varied according to the Oracle installation.
If I use the app.config to redirect the dll, then I have to know in advance the GAC version and it will look like this:
<?xml version="1.0" encoding="utf-8" ?>
<!-- Assembly versions can be redirected in application,
publisher policy, or machine configuration files. -->
<bindingRedirect oldVersion="22.214.171.124" newVersion="126.96.36.199" />
but what we need is newVersion="x.x.x.x" or newVersion="y.y.y.y" or newVersion="z.z.z.z"
Is there is a way to do this without loading the dll explicitly in run-time by code?
You can specify a range for OldValue. See: http://msdn.microsoft.com/en-us/library/eftw1fys.aspx
That said, you might want to test it. I've had strange difficulties with applications compiled against 11g references that got redirected to run against the 10g client and I found it better just to avoid doing that.
That can't be done with a redirect, unless there's some hidden functionality in the framework I don't know about. What you'd actually want to do is release the app with a reference to the lowest supported version, since ODP.net itself installs policy redirects to higher versions. (If you reference 11.1 in your application and the system has 11.2 on it, the policy handles the redirect for you and it picks up 11.2.)
IIRC 11 actually has policy that goes back to 10, so you just need to reference 10 when you release it and it should work fine with 10 or 11.
Thanks, I'll look at this direction(although it is raising other problems for us, but I'll put them aside for now).
One thing that I have noticed is that for .NET Framework 4 Oracle.Dataaccess.dll there isn't policies that goes down to version 10 which might be a problem because .NET Framework 4 is prerequisite for our software.
There is no version of 10g built on .net framework 4. It supported framework versions 1.1 and 2.
For .net 4, you need Oracle Client 11.2 release 2 (188.8.131.52.2 appears to be the earliest version). Another solution would be to look at the managed client beta, which if it has everything you need doesn't require an Oracle client installation at all and greatly simplifies things.
Lets describe the following scenario:
I'm creating .NET Framework 4 application which reference Oracle 10g Oracle.Dataaccess.dll (.NET Framework 2 dll), I install my application on a machine running Oracle 11g client.
From what you know, do you think that Oracle 11g has a policy that will redirect the compiled version 10 Oracle.Dataaccess.dll to version 11 Oracle.Dataaccess.dll that is actaully installed?
I made the test, does not work.
If the dll is compiled with 10g Oracle.Dataaccess.dll it is not running relaying on Oracle policies if the hosting machine is installed only with 11g client with Framework 4 Oracle.Dataaccess.dll.
Tridus, thanks for all of your help.
I hope that finally we'll not have to support both Oracle 10g and 11g.