views:

3527

answers:

5

Hi, I'm using Visual Studio 2008 Express Edition, and I'm trying my hand in developing a small application using Oracle.DataClient. I'm getting the above mentioned error, when trying to connect to the database in the target system.

I've added a reference to Oracle ODP.net provider for Oracle 10gR2, and in the target machine I have a copy of Oracle 10gR2 database installed. Despite this, I'm getting the error. Before posting this, I read this post at SO, and I have installed the instant client, the error persists. Below is the full error stack.

************** Exception Text **************
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 Employees1.frmLogin.oralogin()
   at Employees1.frmLogin.btnTest_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
API Data Conversion Assistant
    Assembly Version: 0.0.0.1
    Win32 Version: 0.0.0.1
    CodeBase: file:///C:/Documents%20and%20Settings/3i/My%20Documents/My%20Dropbox/Sathya's%20dropbox/VisualStudio%20Releases/APIDataconversion/Application%20Files/API%20Data%20Conversion%20Assistant_0_0_0_3/API%20Data%20Conversion%20Assistant.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.42 (RTM.050727-4200)
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Oracle.DataAccess
    Assembly Version: 2.102.2.20
    Win32 Version: 2.102.2.20

I have Oracle 11g installed on the machine on which I developed the application, and it works fine there, but on the target machine, I'm getting this error. Any inputs will be appreciated.

PS: As mentioned above, the referenced Oracle.DataClient.dll file version corresponds to 10gR2, not 11g.

A: 

Have you created and successfully tested a connection using the ODBC Administrator on your client system?

There is a patch out for a permissions issue in the 9i and 10g client that results in this error. If you're at 10.2.0.1, you may need to upgrade to 10.2.0.3 to solve this.

DCookie
@dcookie: Yes the ODBC connection is successful, as my SP retrieves data from an MS SQL Server into Oracle tables.
Sathya
A: 

Well I've made my app use Ole DB(System.Data.Oledb namespace ) connection, and it works fine. Considering that the app is just a front end for calling Oracle SP, and there are no values being returned, I guess this approach is approach acceptable, because in the 2 days I spent trying to figure solution to this problem I could've completed lot more development on the app. I'm still open to answers, as I can learn from what mistake I'm committing for any such applications in the future.

Sathya
A: 

I ran into the same problem. If you have the 11g client installed on your machine, then you need to be using the 11g ODP.Net DLL. I had to completely uninstall everything, and then install the 11g client, and then the 11g ODP.NET drivers. The drivers get installed in the GAC and it gets to be kinda a pain.

*Note, it is my understanding from my DBA that this only works if you don't have to connect to any version less than 9i *

We had to do this on our servers also.

HTH

andrewWinn
+1  A: 

I've been looking into this problem further, and you simply need to grab all the appropriate DLL's from the same downloaded version of ODP.Net and put them in the same folder as your Exe file, because ODP.Net is fussy about not mixing version numbers, which is the problem you're seeing (either that or the oci.dll is totally missing, in which case it annoyingly gives the same error).

I've explained how to do this here: http://splinter.com.au/blog/?p=156

Here's the gist of it though:

Chris
A: 

Progress DataDirect offers an ADO.NET provider that is 100% managed, meaning that it can simultaneously connect to Oracle versions 8.x, 9.x, 10.x, and 11.x with no need for the Oracle client libraries - EVER!! If you're tired of dealing with the headaches of the Oracle client and want to start developing using the Entity Framework or similiar advanced .NET development contexts, check out the Connect for ADO.NET Oracle provider at:

http://www.datadirect.com/products/net/net_for_oracle/index.ssp

You can also download a free, 15 day trial of the provider from this location as well.

Good luck!
Mike Frost
Progress DataDirect

Mike Frost