How does Oracle.ManagedDataAccess handle tnsname.ora in version 19.3?

1.6k Views Asked by At

With Oracle.ManagedDataAccess.dll 12 and 18, if you want to use tnsname.ora aliases, then you have to define the Environment Variable TNS_ADMIN with the corresponding path.

I just discovered that the version 19 is able to get the tnsname.ora configuration without this Environment Variable but I'm not sure how?

Neither the web.cong nor the machine.config contains that Environment Variable.

There seems to be a path in Registry Editor but my project still works when I modify the path with erroneous one.

enter image description here

From what I have tested, here is a list of what works and what doesn't :

  • Local client 19.3 with Oracle.ManagedDataAccess 19.3 (and superior) : Works without TNS_ADMIN Env
  • Local client 19.3 with Oracle.ManagedDataAccess 18.6 (and prior) : Doesn't work without TNS_ADMIN Env
  • Local client 12.1 with Oracle.ManagedDataAccess (all versions) : Doesn't work without TNS_ADMIN Env

So i'm wondering why does this particular case work?

Also is there a method inside Oracle.ManagedDataAccess that return the used tnsname.ora path?

Thanks,

2

There are 2 best solutions below

2
On BEST ANSWER

Thanks all for your answers.

I finally found the solution using Process Monitor (thx @WernfriedDomscheit) and filtering the Path column with TNS_ADMIN.

There are two paths in the Registry Editor that contain the TNS_ADMINvariable:

  • HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ODP.NET.Managed\4.122.19.1
  • HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\ORACLE\ODP.NET.Managed\4.122.19.1

I was only trying to remove the non-WOW6432Node path. If I also remove the WOW6432Node one, then Oracle.ManagedDataAccess.dll successfully fail.

3
On

I don't have any experience specifically with Oracle.ManagedDataAccess.dll, but I do know that in general, no client requires TNS_ADMIN to be set. The TNS layer itself has an order of precedence where it looks to find tnsnames.ora, and this is outside of the calling client. First it looks for a TNS_ADMIN environment variable. If that is not set, or tnsnames.ora is not found where TNS_ADMIN points, it next checks the process's current directory. If not found there, it checks $ORACLE_HOME/network/admin. I'd say your statement "if you want to use tnsname.ora aliases, then you have to define the Environment Variable TNS_ADMIN with the corresponding path" is a conclusion you came to based on incorrect interpretation of either reading or observation.