2
votes

I am trying to connect to oracle server located at some IP address but always get error as

System.TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. ---> Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client at Oracle.DataAccess.Client.OracleInit.Initialize() at Oracle.DataAccess.Client.OracleConnection..cctor() --- End of inner exception stack trace --- at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString) at WebApplication1._Default.Page_Load(Object sender, EventArgs e) in C:\Users\Sunil\Documents\Visual Studio 2008\Projects\WebApplication1\WebApplication1\Default.aspx.cs:line 26

Here is a test file

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Oracle.DataAccess.Client;
namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try {
                string oradb = "Data Source=(DESCRIPTION=(ADDRESS_LIST="
                + "(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.11)(PORT=1523)))"
                + "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)));"
                + "User Id=<user id>;Password=<some password>;";

                OracleConnection conn = new OracleConnection(oradb); // C#
                conn.Open();

            }
            catch (Exception  ex){
                Label1.Text = ex.ToString();
            }

        }
    }
}

I have installed oracle 10gR2 client and oracle 10gR2 provider for ASP.NET under Windows Vista. Am I missing anything ?

Problem Partially solved I had installed oracle client after provider

..but now exception showing as

Oracle.DataAccess.Client.OracleException at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure) at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) at Oracle.DataAccess.Client.OracleConnection.Open() at WebApplication1._Default.Page_Load(Object sender, EventArgs e) in C:\Users\Sunil\Documents\Visual Studio 2008\Projects\WebApplication1\WebApplication1\Default.aspx.cs:line 28

3
what oracle version do you have on your server?hallie
I have an extremely similar problem to you. stackoverflow.com/questions/2142877/… If you happen to find some solution let me know. I've only found vague hints online that mention permissions may be wrong or missing somewhere, but I haven't figured out if that is indeed the problem or what permissions are missing and where they're missingBob
@Bob: Are you on windows vista .. run the program as administrator ..that solved the problem for me.Xinus

3 Answers

2
votes

Problem solved ... windows vista security (?) was the problem I ran the program as administrator and everything worked fine

0
votes

It looks like your version of Oracle.DataAccess.dll is out of sync with your Oracle client install. For example, you may be using a recent version of Oracle.DataAccess.dll which requires the Oracle 11 client.

Check the version string of Oracle.DataAccess.dll. I believe that the Oracle 10 DLL is versioned "10.x.y.z" and the Oracle 11 DLL is versioned "2.x.y.z" (yes, it is confusing).

Note that this is not a server versioning issue -- this error is happening as the OracleConnection class tries to initialise itself, long before it gets to talk to a server.

0
votes

You can try seeing if ASP.NET has permissions on the Oracle folder, that may be the cause of your situation