I'm using ODP.NET, Managed Driver Beta (Oracle.ManagedDataAccess.dll) in my C# application to access an Oracle database. This is to replace using the native version of ODP.NET in order to remove all the local dependencies on Oracle Client 10g/11g/etc. so that this needn't have to be installed locally. This is a solution I found here.
This is my C# code:
new OracleConnection("Data Source=ABCDEFG1;User Id=myuserid;Password=mypassword;").Open();
This line is reached and the OracleConnection
object is created successfully thereby suggesting all dependencies are loaded successfully. However, it throws an OracleException on the call to Open()
. The error message is:
Network Transport: Unable to resolve connect hostname
My organisation performs hostname lookups using LDAP and this is done via the ORA files using DIRECTORY_SERVER setting. However, I'm having difficulty getting it to do this using the managed version of ODP.NET. The ORA files are stored in C:\Apps\oracle\network\admin.
tnsping on my data source ('ABCDEFG1') works fine. So, I used the output of tnsping and added an entry for ABCDEFG1 in tnsnames.ora using this output. My application then connected successfully. So, I know that it is definitely finding and using the ORA files, but, for some reason, it won't perform the LDAP lookup that non-managed ODP.NET (in other applications) uses.
Is anyone who's used this new managed ODP.NET aware of this problem or what I might be doing wrong?