The provider is not compatible with the version of Oracle client

前端 未结 27 1127
一生所求
一生所求 2020-11-22 05:37

I\'m trying to use the Oracle ODP.NET 11g (11.1.0.6.20) Instant Client on my ASP.net project as a Data Provider but when I run the aspx pag

相关标签:
27条回答
  • 2020-11-22 06:36

    Lots of theoretical answers here, but here comes a working example with code that you can copy and paste and test immediately:

    1. I installed the Oracle Express database OracleXE112 which already comes with some preinstalled demo tables.
    2. When you start the installer you are asked for a password. I entered "xxx" as password. (not used in production)
    3. My server runs on the machine 192.168.1.158
    4. On the server you must explicitely allow access for the process TNSLSNR.exe in the Windows Firewall. This process listens on port 1521. If you get a timeout error from the below code check your firewall.
    5. OPTION A: For C# (.NET2 or .NET4) you can download ODAC11, from which you have to add Oracle.DataAccess.dll to your project. Additionally this DLL depends on: OraOps11w.dll, oci.dll, oraociei11.dll (130MB!), msvcr80.dll. These DLLs must be in the same directory as the EXE or you must specify the DLL path in: HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.112.4.0\DllPath. On 64 bit machines write additionally to HKLM\SOFTWARE\Wow6432Node\Oracle\...
    6. OPTION B: If you have downloaded ODAC12 you need Oracle.DataAccess.dll, OraOps12w.dll, oci.dll, oraociei12.dll (160MB!), oraons.dll, msvcr100.dll. The Registry path is HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.121.2.0\DllPath
    7. OPTION C: If you don't want huge DLL's of more than 100 MB you should download ODP.NET_Managed12.x.x.x.xxxxx.zip in which you find Oracle.ManagedDataAccess.dll which is only 4 MB and is a pure managed DLL which works in 32 bit and 64 bit processes as well and depends on no other DLL and does not require any registry entries.
    8. The following C# code works for me without any configuration on the server side (just the default installation):
    using Oracle.DataAccess.Client;
    or
    using Oracle.ManagedDataAccess.Client;
    
    ....
    
    string oradb = "Data Source=(DESCRIPTION="
        + "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.158)(PORT=1521)))"
        + "(CONNECT_DATA=(SERVER=DEDICATED)));"
        + "User Id=SYSTEM;Password=xxx;";
    
    using (OracleConnection conn = new OracleConnection(oradb)) 
    {
        conn.Open();
        using (OracleCommand cmd = new OracleCommand())
        {
            cmd.Connection  = conn;
            cmd.CommandText = "select TABLESPACE_NAME from DBA_DATA_FILES";
    
            using (OracleDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    listBox.Items.Add(dr["TABLESPACE_NAME"]);
                }
            }
        }
    }
    0 讨论(0)
  • 2020-11-22 06:37

    I encountered this problem after I installed Oracle Data Tools for Visual Studio 2015, and then fighting with Oracle for a good hour. I decided to try reinstalling Oracle client again instead of this mess with file copying, config changes, etc., and that worked for me.

    0 讨论(0)
  • 2020-11-22 06:38

    I had the same issue with Oracle.DataAccess.dll v4.121.2.0. with 2- homes installation (32 and 64 bit versions). 32-bit version workerd, 64-bit version didn't.

    In my case (after 2 days of trying) I found that the problem was permissions on the 64-bit-home version. Many Directories in that version had exclusively overridden permissions where "Authenticated Users" role did not have "Read" access, which is set by default on the parent directory. Those sub-directories included "bin", "network/admin", "nls", "oracore", "RDBMS" and possibly others. I found them by filtering out "ACCESS DENIED" result in "Process Monitor" (Procmon.exe) utility from sysinternals. Once the permissions were inherited from the parent directory to those child subdirectories everything started to work.

    I didn't what to override the permissions on the whole oracle home so I did them one directory at a time, but I guess if you don't worry about security so much you can reset it on the whole corresponding oracle home directory.

    0 讨论(0)
提交回复
热议问题