错误“无法找到请求的 .Net Framework 数据提供程序。它可能未安装”

发布于 2024-12-06 13:50:11 字数 726 浏览 0 评论 0原文

我使用的是 Visual Studio 2008 和 Oracle 数据库 10g。

我尝试像这样连接到后端:

子窗口“服务器资源管理器”。按下“连接到数据库”按钮并创建下一个链 数据连接->选择数据源->Oracle数据库->oracle Data provider for .Net->继续->数据源名称:oraclexe->用户名:hr密码:hr->测试连接(回答“测试连接成功”)-> 按钮“确定”并且:

"Unable to find the requested .Net Framework Data Provider. It May not be installed"

我已对 machine.config 进行了更改

<add name="Oracle Data Provider for .NET" 
invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET"
type="Oracle.DataAccess.Client.OracleClientFactory, 
Oracle.DataAccess, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342" />

,但同样的错误仍然存​​在。该怎么办?

I am using Visual Studio 2008 and oracle database 10g.

I trying to connect to the backend like this:

Subwindow "Server explorer". Push button "Connect to database" and make next chain
Data Connection->Choose Data Source->Oracle Database->oracle Data provider for .Net->Continue->Data Source name : oraclexe->Userneme: hr password: hr -> Test connection (answer "Test connected succeeded ")->push button OK and:

"Unable to find the requested .Net Framework Data Provider. It May not be installed"

I have made changes to machine.config

<add name="Oracle Data Provider for .NET" 
invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET"
type="Oracle.DataAccess.Client.OracleClientFactory, 
Oracle.DataAccess, Version=2.111.6.20, Culture=neutral, PublicKeyToken=89b483f429c47342" />

But then to same error persists. What to do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若能看破又如何 2024-12-13 13:50:11

Oracle 数据提供者特定于架构。如果您下载 64 位驱动程序,则需要将应用程序构建为 64 位(如果目标操作系统为 64 位,则构建为 AnyCPU)。

问题是Visual Studio是32位的,所以你还需要安装32位的驱动程序。

Oracle data providers are specific for an architecture. If you download a 64-bit driver you need to build your application as 64bit (or AnyCPU if the target OS is 64bit).

The problem is that Visual Studio is 32-bit, so you also need a 32bit driver installed.

世界如花海般美丽 2024-12-13 13:50:11

一些建议:

  1. 不要使用 EF beta。如果这样做,请使用 32 位版本。截至 2010 年 10 月,该驱动程序并不像宣传的那样工作,除了其他问题外,64 位应用程序的安装配置错误,并且 odac dll 被放置在错误的系统文件夹中。
  2. 如果您正在使用其他人的项目或从其他地方下载它,请坚持使用 ado.net 并在处理该项目之前执行一些简单的查询。
  3. Visual Studio 项目文件在项目文件中保留程序集的建议位置,查找这些位置并删除“提示”路径(如果这是其他人的项目)。
  4. 下载并安装客户端文件:
    http://www.oracle.com/technology/software/tech /windows/odpnet/index.html 因为您没有指定安装了客户端文件。

总之,您可能使用一个版本的驱动程序作为设计工具,而使用另一个版本的驱动程序作为底层连接。我知道这听起来很奇怪,但我已经遇到过好几次了。唯一的出路就是把它拆开。如果您从 ADO.NET 基本连接测试开始,您就会发现问题。

下面是一个简单的入门连接。

谢谢,

奥尔多

using System;
using System.Data.Common;
using Oracle.DataAccess.Client;

namespace EntityFrameworkForOracle
{
    internal class Test1Connection
    {
        internal void InternalTestRead()
        {
            using (var con = Database.GetLocalConnection())
            {
                con.Open();
                var cmd = Database.GetCommand(con);

                const string sql = @"select *
                            from TESTTABLE";

                cmd.CommandText = sql;
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Console.WriteLine("\t{0}\t{1}", reader[0], reader[1]);
                }

                reader.Close();

                con.Close();
                con.Dispose();

                cmd.Dispose();
            }
        }

    }

    public static class Database
    {
        private const string ProviderName = "Oracle.DataAccess.Client";
        private const string LocalConnectionString = "User Id=system;Password=XXX;Data Source=localhost:XXXX/XXXX;enlist=true;pooling=true";

        private static readonly DbProviderFactory Factory = DbProviderFactories.GetFactory(ProviderName);

        public static DbCommand GetCommand(DbConnection con)
        {
            var cmd = Factory.CreateCommand();
            if (cmd != null)
            {
                cmd.Connection = con;

                return cmd;
            }
            return null;
        }

        public static DbCommand GetCommand(string cmdText, DbConnection con)
        {
            var cmd = GetCommand(con);
            cmd.CommandText = cmdText;

            return cmd;
        }

        public static DbConnection GetLocalConnection()
        {
            var con = Factory.CreateConnection();
            if (con != null)
            {
                con.ConnectionString = LocalConnectionString;

                return con;
            }
            return null;
        }

        public static void CloseConnection(OracleConnection connection)
        {
            connection.Close();
            connection.Dispose();
        }
    }

}

A couple of suggestions:

  1. Don't use the EF beta. If you do, use the 32-bit version. The driver does not work as advertised as of October 2010, the install was misconfigured for 64 bit applications and odac dll's were placed in the wrong system folder, aside from other issues.
  2. Stick with ado.net and do some simple queries before tackling the project, if you are using someone else's project or downloaded it from somewhere.
  3. Visual studio project files keep suggested locations for assemblies in the project file, look for those and remove the "hint" path if this is someone else's project.
  4. Download and install the client files:
    http://www.oracle.com/technology/software/tech/windows/odpnet/index.html since you did not specify that you have the client files installed.

In summary, you are probably using one version of the driver for the design tool and another for the underlying connections. I know this sounds weird but I've run into it several times already. The only way forward is to take it apart. If you start with an ADO.NET base connection test you'll find the problem.

Below is a simple connection to get started.

Thanks,

Aldo

using System;
using System.Data.Common;
using Oracle.DataAccess.Client;

namespace EntityFrameworkForOracle
{
    internal class Test1Connection
    {
        internal void InternalTestRead()
        {
            using (var con = Database.GetLocalConnection())
            {
                con.Open();
                var cmd = Database.GetCommand(con);

                const string sql = @"select *
                            from TESTTABLE";

                cmd.CommandText = sql;
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Console.WriteLine("\t{0}\t{1}", reader[0], reader[1]);
                }

                reader.Close();

                con.Close();
                con.Dispose();

                cmd.Dispose();
            }
        }

    }

    public static class Database
    {
        private const string ProviderName = "Oracle.DataAccess.Client";
        private const string LocalConnectionString = "User Id=system;Password=XXX;Data Source=localhost:XXXX/XXXX;enlist=true;pooling=true";

        private static readonly DbProviderFactory Factory = DbProviderFactories.GetFactory(ProviderName);

        public static DbCommand GetCommand(DbConnection con)
        {
            var cmd = Factory.CreateCommand();
            if (cmd != null)
            {
                cmd.Connection = con;

                return cmd;
            }
            return null;
        }

        public static DbCommand GetCommand(string cmdText, DbConnection con)
        {
            var cmd = GetCommand(con);
            cmd.CommandText = cmdText;

            return cmd;
        }

        public static DbConnection GetLocalConnection()
        {
            var con = Factory.CreateConnection();
            if (con != null)
            {
                con.ConnectionString = LocalConnectionString;

                return con;
            }
            return null;
        }

        public static void CloseConnection(OracleConnection connection)
        {
            connection.Close();
            connection.Dispose();
        }
    }

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文