Click here to Skip to main content
15,905,238 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi All,

I am getting the following exception when I am trying to connect to Oracle using .Net code.

The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.

the inner exception gives the following message.

"The provider is not compatible with the version of Oracle client."

I have lot of solutions on net and little confused in understanding the real problem.

My project Environment.

1. Oracle 11g.
2. Oracle Client version
SQL*Plus: Release 11.2.0.2.0
3. Visual Studio 2010 - Calling Oracle from WCF service
4. Oracle Home - C:\Oracle\Product\11.2.0\client_2
5. ODP.NET version
C:\Oracle\Product\11.2.0\client_2\odp.net\bin\2.x - 2.112.2.0
C:\Oracle\Product\11.2.0\client_2\odp.net\bin\4 - 4.112.2.0

I am little curious to know whether this exception is coming because of some ODP.NET issue or some other .dll issue.

However, on the contrary if I am using the .asmx to connect to the Oracle it is working fine.

Please help me in understanding the real problem whether it is at the client side or the server side where the WCF service is deployed.

Thanks in advance.

"Happy Coding"
Posted

1) Check if you are compiling to x86 or Any CPU (Any CPU is preferred since it will work on 64bit and 32bit and possibly your asmx is 64bit which is working).

2) Check your .net versions you are building with in your projects.
 
Share this answer
 
Comments
Kenji Kumakura 2-Aug-13 11:59am    
In my case changing platform target to x86 solved the problem.
Hello,

The error kind of suggests that it's the problem with the dependencies. Please check whether you are using correct versions of depenencies with ODP.NET provider. You may find this blog post[^] useful in resolving this issue.

Regards,
 
Share this answer
 
Thanks guys for your replies.
I got this problem solved. I was actually missing the correct version of Oracle.DataAccess.dll

I added Oracle.DataAccess.dll -4.112.3 in the Bin of my executable and got it resolved.
 
Share this answer
 
Comments
Aaanand 24-Jan-18 16:32pm    
I had same issue and tried to follow your route and installed ODP.Net to get Oracle.Dataaccess 4.112.3 in ref and started getting this error:
"Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format."
I tried "Any CPU, "x86" and "x64" but none of any worked..
if I put my old dll 4.112.2, it again gives oracle driver issue but this assmebly error doesnt come..
Member 13794998 22-Nov-18 16:08pm    
I Tried all possible ways still I have no luck. Can anyone help me with the below error
the provider is not compatible with the version of oracle client at oracle.dataaccess.client.oracleinit.initialize()

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900