I'm using the Oracle.ManagedDataAccess Nuget Package Version 12.2.1100 in my C# (>.NET 4.0) project. Everything works ok in my localhost but on the dev server I'm hit with this exception:
Exception Message: ORA-12154: TNS:could not resolve the connect identifier specified Exception Source: Oracle Data Provider for .NET, Managed Driver
Now I thought the ManagedDataAcess contained everything I needed. Am I missing something else? Is something else interfering with the package? Do I need to add something else?
Note: there is no <oracle.manageddataaccess.client>
tag in my Web.config
Code:
<connectionStrings>
<add name="XXX" connectionString="Data Source=XXX;User ID=XXX;Password=XXX" />
</connectionStrings>
EDIT:
I've confirmed that the TNS_ADMIN variable is set within Control Panel but that didn't seem to do the trick.
I then added the tnsnames.ora file to the bin folder and I've got it working but it isn't a long term solution.
Your program does not find the tnsnames.ora
(resp. sqlnet.ora
) file. There are several possibilities to specify the location.
Define it in .NET config file (web.config
, machine.config
, application.config
)
Set environment variable TNS_ADMIN
Copy tnsnames.ora
, sqlnet.ora
files to directory where your application .exe is located.
Example for .NET config file:
<oracle.manageddataaccess.client>
<version number="4.122.*">
<settings>
<setting name="TNS_ADMIN" value="C:\oracle\network\admin"/>
</settings>
</version>
</oracle.manageddataaccess.client>
Note, unlike other drivers/providers the ODP.NET Managed driver does not read the TNS_ADMIN
setting from Registry.