c# – ODP.NET连接异常

前端之家收集整理的这篇文章主要介绍了c# – ODP.NET连接异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
首先,我想说我对Oracle数据库一点也不熟悉,所以我的话可能选择不当,而且我对某些概念的理解可能是错误的……
无论如何,我试图使用ODP.NET连接到Oracle 11g数据库,每次它给我这个例外: @H_301_3@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 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:

来自:

@H_301_3@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服务.

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

@H_301_3@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下的注册表中的某个密钥上找到).所以文件内容来自

@H_301_3@sqlNET.AUTHENTICATION_SERVICES= (none) NAMES.DIRECTORY_PATH= (LDAP,TNSNAMES,EZCONNECT)

@H_301_3@sqlNET.AUTHENTICATION_SERVICES= (none) NAMES.DIRECTORY_PATH= (EZCONNECT,TNSNAMES)

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

希望它可以帮助别人!

原文链接:https://www.f2er.com/csharp/100958.html

猜你在找的C#相关文章