连接错误:Oracle.DataAccess.Client.OracleException ORA-12170

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2570912/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 20:21:00  来源:igfitidea点击:

Connection Error:Oracle.DataAccess.Client.OracleException ORA-12170

.netoraclelistenertnsora-12170

提问by psyb0rg

This has taken many hours of mine. I have to get this .Net app to run on an XP system. Someone seems to have messed up some files so conn.Open() in the C# is causing this error:

这花了我很多小时。我必须让这个 .Net 应用程序在 XP 系统上运行。有人似乎弄乱了一些文件,所以 C# 中的 conn.Open() 导致了这个错误:

    Connection Error:Oracle.DataAccess.Client.OracleException ORA-12170: 
TNS:Connect timeout occurred at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection 
conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure) at 
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, 
IntPtr opsErrCtx, Object src) at Oracle.DataAccess.Client.OracleConnection.Open() at 
Service.connect(Int32 sql_choice, String databaseIdentifier, String authenticationKey) in 
c:\Documents ....

This is my sqlnet.ora file:

这是我的 sqlnet.ora 文件:

# sqlnet.ora Network Configuration File: C:\oracle\product.2.0\db_1\network\admin\sqlnet.ora

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

SQLNET.INBOUND_CONNECT_TIMEOUT = 180
SQLNET.SEND_TIMEOUT = 180
SQLNET.RECV_TIMEOUT = 180

This is tnsnames.ora:

这是 tnsnames.ora:

# tnsnames.ora Network Configuration File: C:\oracle\product.2.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

ORACLE2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dell )(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = oracle2)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dell )(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

This is listener.ora:

这是listener.ora:

# listener.ora Network Configuration File: C:\oracle\product.2.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = C:\oracle\product.2.0\db_1)
      (PROGRAM = extproc)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dell  )(PORT = 1521))
    )
  )

I've tried changing the host name to localhost, 127.0.0.1 but that doesn't work. Also,

我已经尝试将主机名更改为 localhost, 127.0.0.1 但这不起作用。还,

  • I can execute queries from SQL Plus.
  • There are NO firewalls on the system
  • The .Net app and DB are on the same machine.
  • 我可以从 SQL Plus 执行查询。
  • 系统上没有防火墙
  • .Net 应用程序和 DB 在同一台机器上。

回答by DCookie

A similar SO questionwas solved when it was determined that the database was installed on a Windows box using DHCP. As I said in that answer, the Microsoft Loopback Adapter needs to be installed if you use DHCP on a Windows box with Oracle.

一个类似的SO问题,当它被确定数据库安装在使用DHCP Windows中得到解决。正如我在那个答案中所说,如果您在带有 Oracle 的 Windows 机器上使用 DHCP,则需要安装 Microsoft Loopback Adapter。