我收到以下错误
ExceptionMessage: "ORA-12541: TNS: No listener"
ExceptionType: "Oracle.ManagedDataAccess.Client.OracleException"
InnerException: {Message: "An error has occurred.", ExceptionMessage: "ORA-12541: TNS: No listener",…}
ExceptionMessage: "ORA-12541: TNS: No listener"
ExceptionType: "OracleInternal.Network.NetworkException"
InnerException: {Message: "An error has occurred.",…}
ExceptionMessage: "No connection could be made because the target machine actively refused it {internal_ip}:1521"
ExceptionType: "System.Net.Sockets.SocketException"
Message: "An error has occurred."
StackTrace: " at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
↵ at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
↵ at OracleInternal.Network.TcpTransportAdapter.ConnectIterate()"
Message: "An error has occurred."
StackTrace: " at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
↵ at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName)"
Message: "An error has occurred."
StackTrace: " at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
↵ at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
↵ at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
↵ at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
在我的配置文件中使用以下别名。请注意,配置文件中的端口是 1522,但错误引用了端口 1521。
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="ConnectionOne" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST={host})(PORT=1522))(CONNECT_DATA=(SERVICE_NAME={service_name}))) " />
</dataSources>
</version>
</oracle.manageddataaccess.client>
更改连接字符串
<connectionStrings>
<add name="ConnectionOne"
connectionString="user id = ; password = ; data source = ConnectionOne"/>
</connectionStrings>
至
<connectionStrings>
<add name="ConnectionOne"
connectionString="user id = ; password = ; data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST={host})(PORT=1522))(CONNECT_DATA=(SERVICE_NAME={service_name})))"/>
</connectionStrings>
解决问题。
来自 Oracle 文档(https://docs.oracle.com/cd/E63277_01/win.121/e63268/InstallManagedConfig.htm#ODPNT8161)
遵循以下优先顺序来解析连接字符串中数据源属性中指定的数据源别名。
- .NET 配置文件中 <oracle.manageddataaccess.client> 部分下的 dataSources 部分中的数据源别名。
- tnsnames.ora 文件中的数据源别名,位于 .NET 配置文件中 TNS_ADMIN 指定的位置。位置可以由绝对或相对目录路径组成。
- 与 .exe 位于同一目录中的 tnsnames.ora 文件中的数据源别名。
所以,我不认为它是从另一个位置读取的。
有谁知道这可能是什么原因?