为什么不Oracle.ManagedDataAccess时Oracle.DataAccess做工作? [英] Why would Oracle.ManagedDataAccess not work when Oracle.DataAccess does?

查看:1166
本文介绍了为什么不Oracle.ManagedDataAccess时Oracle.DataAccess做工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个非常简单的应用程序,我打算用它来解决我的几个机器但在此之前我甚至有远我碰到的几个问题,包括CPU架构的差异和Oracle数据库库有一个问题。

I'm developing a very simple application which I intend to use to troubleshoot an issue I am having on a few machines but before I even got that far I ran into a few issues, including cpu architecture differences and Oracle database libraries.

我在的tnsnames.ora 中列出的数据库服务器,坐在我的 C:\\ ORACLE \\11克\\网络\\ ADMIN 目录。如果我用tnsping这台服务器我获得所需的响应。如果我code我的C#程序与使用Oracle.DataAccess.Client以下code连接到这台服务器,它的工作原理。

I have a database server listed in tnsnames.ora, sitting in my C:\oracle\11g\network\admin directory. If I tnsping this server I get the desired response. If I code my C# program to connect to this server with the following code using Oracle.DataAccess.Client, it works.

string connectionString = "Data Source=DSDSDS;User Id=UNUNUN;Password=PWPWPW;";
DataTable dataTable = new DataTable();

using (var connection = new OracleConnection(connectionString)) {
    connection.Open();
    using (var command = new OracleCommand()) {
        command.Connection = connection;
        command.CommandText = sql;
        command.CommandType = CommandType.Text;
        using (var oda = new OracleDataAdapter(command)) {
            oda.Fill(dataTable);
        }
    }
}

然而Oracle.DataAccess依赖于该系统的体系结构在其上运行。我看到有其他库Oracle.ManagedDataAccess这是体系结构无关。当我使用这个库不再能够连接到服务器。一个 ORA-12545:网络传输:无法解析主机连接被抛出

为什么会出现这种情况?因为根据我读过迄今这不应该是一个问题,什么是这两个库之间的不同。

Why is this the case? What is different between these two libraries because based upon what I've read thus far this shouldn't be an issue.

的额外信息:


  • %ORACLE_HOME%和%TNS_ADMIN%没有定义(记住,TNSPING和Oracle.DataAccess工作)

  • 路径有 C:\\ ORACLE \\11克\\ BIN 定义

  • 我的机器只有一个的tnsnames.ora 文件

  • %ORACLE_HOME% and %TNS_ADMIN% are NOT defined (remember that tnsping and Oracle.DataAccess work)
  • PATH has C:\oracle\11g\BIN defined.
  • My machine only has one tnsnames.ora file

如果我移动到tnsnames.ora中相同的位置作为我的.exe文件,它的工作原理。 Oracle.DataAccess为什么可以找到Ç的tnsnames.ora:\\ ORACLE \\11克\\网络\\ ADMIN 目录,但Oracle.ManagedAccess不能

If I move tnsnames.ora to the same location as my .exe file, it works. Why can Oracle.DataAccess find tnsnames.ora in the C:\oracle\11g\network\admin directory but Oracle.ManagedAccess cannot?

推荐答案

precedence在ODP.NET解决TNS名字的顺序,管理驱动程序是这样的(见的here ):

The order of precedence for resolving TNS names in ODP.NET, Managed Driver is this (see here):


    下在.NET配置文件部分数据源部分
  1. 数据源别名。

  2. 数据源别名在由.NET配置文件TNS_ADMIN指定的位置tnsnames.ora文件。

  3. 数据源别名在同一目录中的.exe tnsnames.ora文件present。

  4. 数据源别名在%TNS_ADMIN%(其中,%TNS_ADMIN%是一个环境变量设置)tnsnames.ora文件present。

  5. 数据源别名在%ORACLE_HOME%\\网络\\管理员(其中%ORACLE_HOME%是一个环境变量设置)tnsnames.ora文件present。

我相信你的样本可以与Oracle.DataAccess但不能与Oracle.ManagedDataAccess的原因是基于Windows注册表中的配置不支持后者(见的documentation ) - 在ODP.NET安装设置一个ORACLE_HOME注册表项(HLKM \\ SOFTWARE \\ ORACLE \\ KEY_NAME \\ ORACLE_HOME),这是由只承认非托管的部分。

I believe the reason your sample works with Oracle.DataAccess but not with Oracle.ManagedDataAccess is that Windows registry based configuration is not supported for the latter (see documentation) - the ODP.NET installation sets an ORACLE_HOME registry key (HLKM\SOFTWARE\Oracle\Key_NAME\ORACLE_HOME) which is recognized only by the unmanaged part.

这篇关于为什么不Oracle.ManagedDataAccess时Oracle.DataAccess做工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆