c# - 找不到类型或命名空间名称 'OracleConnection'

标签 c# asp.net namespaces oracleclient system.data.oracleclient

每次我尝试调试我的程序时都会收到此错误:

CS0246: The type or namespace name 'OracleConnection' could not be found (are you missing a using directive or an assembly reference?)

这发生在声明 private readonly OracleConnection oracleConnection; 上(以及其他一些地方)

我一直在尝试一些建议的解决方案,但到目前为止都没有奏效:

  • 我添加了对 System.Data.OracleClient.dll 的引用
  • 我的目标框架设置为 .NET Framework 4
  • 我都尝试过,包括使用 System.Data.OracleClient 和手动写出 System.Data.OracleClient.OracleConnection

编辑:我使用的代码如下:

using System;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Foo
{
    public class DBHandler
    {
        private readonly OracleConnection oracleConnection;
        private readonly OracleCommand oracleCommand;
        private readonly OracleDataAdapter oracleAdapter;

到目前为止没有任何效果,因此我们将不胜感激。

最佳答案

首先,对于 Oracle,System.Data.OracleClient 已被弃用,因此现在不推荐使用。详情请浏览ADO.NET Team Blog Post

推荐使用Oracle公司发布的Oracle客户端。从 Oracle .NET Developer Center 下载 Oracle 数据访问组件

然后以同样的方式,您可以通过添加对 Oracle.Client dll 的引用来使用 OracleConnection、OracleCommand 等。

另外请注意,此库不适用于 .NET 4 Client Profile。

关于c# - 找不到类型或命名空间名称 'OracleConnection',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12220095/

相关文章:

c# - 使用证书公钥验证 java 中的签名

c# - 通过 asp.net 访问 Office Word 对象模型导致 "failed due to the following error: 80070005 Access is denied."

xml - XSLT - 将 namespace 添加到输出

c# - WCF- "The underlying connection was closed: The connection was closed unexpectedly"

c# - 如何从 C# 中的相对 URL 字符串获取参数?

c# - MVC4错误-路由表中没有路由匹配

javascript - jquery UI 模式不会导致回发

asp.net - 将 &lt;script&gt; 标签注入(inject)到代码后面的 <head> 中

php - Composer 找不到类并加载它们

razor - 为什么 Razor 看不到包含的命名空间?