First I would like to say that I am not familiar at all with Oracle databases, so my words might be poorly chosen and my understanding of some concept might be wrong... Anyway, I am trying to connect to an Oracle 11g database using ODP.NET and every time it gives me this exception :
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:
Called from :
private System.Data.IDbConnection _dbConnection;
public override IDbConnection DbConnection
{
get
{
if (_dbConnection.State == ConnectionState.Closed)
_dbConnection.Open(); // Crash from HERE
return _dbConnection;
}
}
EDIT Additional info : am also trying to connect without the tnsname.ora file. This is a windows service running on the same server that the database is located on.
I tried the following connection strings, the first one works in debug (and is the one constructed by the application) :
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;
Any idea ?
This guy helped me solve my problem https://pravsdatums.wordpress.com/2013/12/16/ocac-12c-and-visual-studio-developer-tools/#comment-1
The solution was to remove LDAP from NAMES.DIRECTORY_PATH in the sql.ora file. This file is located on your client home directory (this path can be found on one of the key in the registry under HLM/SOFTWARE/ORACLE). So the content of the file went from
SQLNET.AUTHENTICATION_SERVICES= (none)
NAMES.DIRECTORY_PATH= (LDAP, TNSNAMES, EZCONNECT)
To
SQLNET.AUTHENTICATION_SERVICES= (none)
NAMES.DIRECTORY_PATH= (EZCONNECT, TNSNAMES)
And now it works ! I don't know why it was working on my development machine (maybe because Oracle is not installed on it).
Hope it can help somebody else !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With