Oracle Managed ODP.NET can't find tnsnames.ora

SeanKilleen picture SeanKilleen · Mar 7, 2013 · Viewed 13.2k times · Source

My managed ODP.net webapp works locally but when deploying it to a server, it fails with the error:

"TNS:listener does not currently know of service requested in connect descriptor"

From looking around, it seems like this is because it can't get to the tnsnames.ora file.

I have tried the following with no success:

  • Placing a tnsnames.ora file (the same one that works locally) into an [oracle home][product]...\network\admin folder.
  • Setting a TNS_ADMIN setting in the Managed ODP's web.config section pointing to the environment variable.
  • Setting the TNS_ADMIN setting in the Managed ODP's web.config section pointing directly to the tnsnames.ora file.

On the server, attempting to run tnsping yields error TNS-03502: Message 3502 not found; No message file for product=NETWORK, facility=TNS

What am I missing?

Answer

Branko Dimitrijevic picture Branko Dimitrijevic · Apr 8, 2013

Try using a connection string that doesn't depend on tnsnames.ora, such as:

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;