本文介绍了ODP.NET连接异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想说,我不熟悉Oracle数据库的好,所以我的话可能会选择不好,我的一些概念的理解可能是错误的...
无论如何,我尝试连接使用ODP.NET和每一个它给了我这个异常时的Oracle 11g数据库:

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:

从名为:

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服务。

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 problemhttps://pravsdatums.wordpress.com/2013/12/16/ocac-12c-and-visual-studio-developer-tools/#comment-1

解决的办法是从NAMES.DIRECTORY_PATH在sql.ora文件中删除LDAP。此文件位于在客户端的主目录(该路径可以在HLM下/ SOFTWARE / ORACLE注册表中的重点之一中找到)。因此,文件的内容从

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)

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).

希望它可以帮助别人!

这篇关于ODP.NET连接异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 13:07