gpt4 book ai didi

c# - ODP.NET 连接异常

转载 作者:太空狗 更新时间:2023-10-29 20:23:51 25 4
gpt4 key购买 nike

首先我想说我对 Oracle 数据库一点都不熟悉,所以我的措辞可能不正确,我对某些概念的理解可能是错误的......无论如何,我正在尝试使用 ODP.NET 连接到 Oracle 11g 数据库,每次它都会给我这个异常:

System.TypeInitializationException occurred
HResult=-2146233036
Message=The type initializer for 'OracleInternal.Network.AddressResolution' threw an exception.
Source=Kiwi.ServiceBase
TypeName=OracleInternal.Network.AddressResolution
StackTrace:
at OracleInternal.ConnectionPool.PoolManager`3.CreateNewPR(Int32 reqCount, Boolean bForPoolPopulation, ConnectionString csWithDiffOrNewPwd, String instanceName)

at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch)

at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, String affinityInstanceName, Boolean bForceMatch)

at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword)

at Oracle.ManagedDataAccess.Client.OracleConnection.Open()

at Kiwi.DataAccess.OracleDataService.get_DbConnection() in c:\Projects\Kiwi-Beta7-0\Kiwiweb\src\Common\ApplicationServices\DataService\OracleDataService.cs:line 28

InnerException: System.TypeInitializationException
HResult=-2146233036
Message=The type initializer for 'OracleInternal.Network.LDAP' threw an exception.
Source=Oracle.ManagedDataAccess
TypeName=OracleInternal.Network.LDAP
StackTrace:
at OracleInternal.Network.LDAP..ctor()
at OracleInternal.Network.AddressResolution..cctor()
InnerException: System.NullReferenceException
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Oracle.ManagedDataAccess
StackTrace:
at OracleInternal.Network.LDAP._LDAP(Hashtable dsMap)
at OracleInternal.Network.LDAP..cctor()
InnerException:

调用自:

private System.Data.IDbConnection _dbConnection;
public override IDbConnection DbConnection
{
get
{
if (_dbConnection.State == ConnectionState.Closed)
_dbConnection.Open(); // Crash from HERE
return _dbConnection;
}
}

编辑 附加信息:我也在尝试在没有 tnsname.ora 文件的情况下进行连接。这是在数据库所在的同一台服务器上运行的 Windows 服务。

我尝试了以下连接字符串,第一个在调试中工作(并且是由应用程序构建的):

Data Source=demosyr20140329:1521/demosyr;User ID=SEI;password=manager;Pooling = False;

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=DEMOSYR20140329)(PORT=1521))(CONNECT_DATA=(SID=DEMOSYR)));User Id=system;Password=manager;

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=DEMOSYR20140329)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=DEMOSYR)));

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=DEMOSYR20140329)(PORT=1521))(CONNECT_DATA=(SID=DEMOSYR))); User Id=system;Password=manager;

User Id=system;Password=manager;Data Source=oracle

Data Source=system/manager@//DEMOSYR20140329:1521/DEMOSYR;

有什么想法吗?

最佳答案

这个人帮我解决了我的问题 https://pravsdatums.wordpress.com/2013/12/16/ocac-12c-and-visual-studio-developer-tools/#comment-1

解决方案是从 sql.ora 文件的 NAMES.DIRECTORY_PATH 中删除 LDAP。此文件位于您的客户端主目录中(此路径可在 HLM/SOFTWARE/ORACLE 下的注册表项之一中找到)。所以文件的内容来自

SQLNET.AUTHENTICATION_SERVICES= (none)

NAMES.DIRECTORY_PATH= (LDAP, TNSNAMES, EZCONNECT)

SQLNET.AUTHENTICATION_SERVICES= (none)

NAMES.DIRECTORY_PATH= (EZCONNECT, TNSNAMES)

现在可以了!我不知道为什么它在我的开发机器上运行(可能是因为它没有安装 Oracle)。

希望对其他人有帮助!

关于c# - ODP.NET 连接异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25508402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com