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

1.6k views Asked by At

I have created a new Console Application project with Visual Studio 2010 (I tried with VS 2012 and the problem is the same). The using are:

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

In the Main method I wrote this code:

   var oracleInstance = OracleClientFactory.Instance;
        using (DbConnection conn = oracleInstance.CreateConnection())
        {
            conn.ConnectionString =
                "Data Source=XXX;Persist Security Info=True;User ID=XXX;Password=XXX;";
            conn.Open();

            var command = conn.CreateCommand();
            command.CommandText = "SELECT * FROM TABLE1 where rownum = 1";

            DbDataReader reader = command.ExecuteReader();


            while (reader.Read())
            {
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    Console.WriteLine("Column number {0}: {1}", i, reader[i]);
                }
            }
}

The target framework is .NET 4.0 . I referenced Oracle.DataAccess.dll 4.112.3.0 (.NET 4).

The problem is: if I target .NET 4.0, the compilation doesn't work and it says The type or namespace name 'Oracle' could not be found (are you missing a using directive or an assembly reference?) If I target .NET 4.0 Client Profile, it works fine. The fact is that I need to target .NET 4.0 framework, NOT .NET 4.0 Client Profile!!

Is there a solution to this problem?

0

There are 0 answers