ODAC 12c and Visual Studio Developer Tools

Recently i had to work on a simple windows forms application that had to do accomplish basic CRUD functions. I thought i might be able to wire up something real quick using visual studio developer tools for oracle and ODAC. I also wanted to use the new managed ODP.net provider instead of the unmanaged provider as it would ease the deployment process. This was a very simple project and i didnt want the overhead of installing the oracle client on the client machines. That would have been an overkill. So i downloaded the latest ODAC from here  . I was currently using both Visual Studio 2010 and 2012 and so while doing the installation you need to choose the correct visual studio version.

If you already have an Oracle client installed, ( i had Oracle 11.2) then the ODAC installation automatically copies the tnsnames.ora and sqlnet.ora to the new locations under 12.1 folder. After installation, i also restarted my machine, though the installation doc didnt mandate it. (i was due for an windows update reboot anyways) .

To test my oracle connections i used the Add Connection dialog from Server Explorer in Visual Studio, and chose Under Data Source, ODP.net Managed Provider.

Upon doing so, I realized that it was not populating the tnsnames entry on the Data Source Name drop down box, if I chose the Managed Provider. However if changed the option to Unmanaged provider, it was populating the tnsnames entries. It was a bit baffling to me, because i was able to tnsping,make an sqlplus connection to the same oracle database (and it was using the tnsnames).

So then i tried using the EZConnect option  (under connection Type) and gave the full details of my database hostname,server etc.
This time I got an error OracleInternal.Network.Addressresolution exception. This was again weird to me. So i googled online to see anyone else had this message, and i found that this message came along with an inner exception indicating why the address resolution failed. However i didnt get any, so i was not sure what was the cause.

I decided to do couple of things

1)I created the TNS_ADMIN environment variable to point to location where my 12.1 tnsnames file was.  ORACLE_HOME/network/admin/

2)I created a simple c# console app (to find out the innerException), and added the connectionString tag to the app.config to point to my database


<add name="MYConnectionString" connectionString="DATA SOURCE=xxx;PASSWORD=xxx;USER ID=xxx"
 providerName="Oracle.ManagedDataAccess.Client" />

and wrote a simple test app trying to get a count from a table in the db. Upon debugging, i found that the app threw the same network resolution error and when i looked at the inner exception, it mentioned that the address resolution failed while reading ldap data. I dont know why it threw that error, because in my sqlnet.ora, i have TNSNAMES first and then LDAP.ora.

My thought was maybe the new managed provided was also trying to look at LDAP.ora and so I decided to copy the ldap.ora from my other Oracle Home to the new 12.1 Oracle Home. Then Voila my console app worked and then when i tried to create a new connection from the add connection dialog, i was able to see my tnsnames entry populated.

OdpConnection

Update: Now after its been working a while, i decided to remove the LDAP.ora file from the TNS_ADMIN location and now it was still populating the tnsnames fine !! I am guessing now that addition of TNS_ADMIN environment variable was good enough? But i swear that was the first thing that i tried, but it didnt populate the entries then. I will update when i find more on this.

One thought on “ODAC 12c and Visual Studio Developer Tools

  1. I was getting the same error. Thanks to you I resolved the issue!

    My problem was that I copied over sqlnet.ora from my DBAs: (Contents Below)

    NAMES.DIRECTORY_PATH= (TNSNAMES, HOSTNAME, LDAP)

    Instead, I should have used the sqlnet.ora provided as a sample: (Contents Below)

    SQLNET.AUTHENTICATION_SERVICES= (NTS)
    NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

    THanks so much!! You saved my day!

Leave a comment