tags:

views:

461

answers:

3

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

A: 

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.

itowlson
@itowlson: Thanks .. Actually I reinstalled provider after installing client :). but now it gave rise to new exception :(
Xinus
Oracle data access version is 10.2.0.100 , but I am now getting new exception which is mentioned in my modified question .
Xinus
Ah, sorry, not sure what might be causing that, though at least now the DLLs seem to be loading okay and we're into the realm of connection issues. Can you determine any kind of error code? It may be buried in the properties of the OracleException -- examine the exception in a debugger and see if there are any clues.
itowlson
A: 

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

Bob
A: 

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

Xinus