问题
I'm developing an app in Visual Studio 2013 that connects to a Oracle Database. I have to use the "Unmanaged Driver". When I'm trying to create a new connection in a dataset, when I chose the "Managed Driver" all work fine: the tnsnames.ora is found. But when I select the "Unmanaged driver" all fails, it send me a message like " Failed to find the default tnsnames.ora file"
I already - Uninstalled all old Oracle Clients - Clean all environment variables - Reinstalled Oracle client, ODP tools for Visual Studio
Nothing seems to work. Any ideas ?
回答1:
you should go to the folder containing the machine.config file. this file is found in %windir%\Microsoft.NET\Framework64\[version]\config\machine.config
make sure you have the following value.
<oracle.manageddataaccess.client>
<version number="4.121.2.0">
<settings>
<setting name="TNS_ADMIN"value="E:\app\client\USERWINDOW\product\12.1.0\client_1\network\admin" />
</settings>
</version>
</oracle.manageddataaccess.client>
Also, refer to this post on Where Is Machine.Config?
回答2:
You can ignore that message and simply use EZ Connect to connect (providing host, port, service_name).
Or you can find a valid TNSNAMES.ORA with your aliases in it, and copy it to: [ORACLE_HOME_WHERE_ODT_IS_INSTALLED]\NETWORK\ADMIN
Since Managed Driver can find TNSNAMES.ORA this means that TNS_ADMIN is set in the machine.config. When you connect using managed provider, the connection dialog will show you where it is finding the TNSNAMES.ORA and you can copy it over.
回答3:
The tnsnames.ora file should be in (installation dir)\network\admin. This is something your dba would provide.
The ORACLE_HOME environment variable is no longer necessary since that information is now found in the registry at HKLM\Software\Oracle.
However, if you have multiple oracle provider installs, it is nice to use the TNS_ADMIN environment variable to point all instances to a centralized folder where a shared tnsnames.ora is located.
回答4:
Please ensure that below entries are present in machine.config so that default tnsnames.ora is correctly pointed to. In my case, entry was missing for unmanaged client and after adding it manually into machine.config, it worked correctly.
machine.config: ..
<oracle.manageddataaccess.client>
<version number="4.121.2.0">
<settings>
<setting name="TNS_ADMIN"
value="C:\app\client\username\product\12.1.0\client_1\network\admin"
/>
</settings>
</version>
</oracle.manageddataaccess.client>
<oracle.unmanageddataaccess.client>
<version number="4.121.2.0">
<settings>
<setting name="TNS_ADMIN"
value="C:\app\client\username\product\12.1.0\client_1\network\admin"
/>
</settings>
</version>
</oracle.unmanageddataaccess.client>
..
回答5:
My solution was: going to the folder "...\product\12.2.0\client_1\odt\vs2017"
and manually install the
vs2017.exe
, and after appeared it in visual studio 2017.
回答6:
I've faced exactly the same issue today. Tried the steps above but didn't helped out.
Afterwards I figured out that on my machine ODAC was installed as well and Visual Studio tried to use the dll from the ODAC client.
After removal all worked like a charm.
回答7:
You can try to create system variable (run Sysdm.cpl): name TNS_ADMIN and value e.g. "c:\app\client\Burn\product\12.2.0\client_1\network\admin\"
来源:https://stackoverflow.com/questions/29233472/visual-studio-odp-unmanaged-driver-failed-to-find-the-default-tnsnames-ora-fil