Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Creating an Oracle connection in Net WCF using ODAC causes Exception

957028Aug 21 2012 — edited Aug 22 2012
Why am I getting a 'System.TypeInitializationException' when I create an Oracle connection in my .Net WCF web service?
=========================================================================

I'm currently working on implementing a WCF service which talks to an Oracle 10g database on the backend. When I attempt to connect to the database from within my service, I get the following exception: System.TypeInitializationException.
•I'm running on a windows 7 (64 bit machine).
•I'm using VS 2010.
•I'm using Oracle 10g on the backend.

I'm the Oracle.DataAccess.dll (ODP.Net) from the following installed instance
c:\oracle\product\10.2.0\.....\ODP.NET\bin\1.x\Oracle.DataAccess.dll

•I've included this DLL in the references for my WCF service.
•I've included this service as a project within my VS WPF solution.
•The service starts up automatically when I start my WPF application in VS 2010.

At runtime I see the following output in my debug output window:


'WcfSvcHost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC\Oracle.DataAccess\1.102.2.20__89b483f429c47342\Oracle.DataAccess.dll' A first chance exception of type 'System.TypeInitializationException' occurred in Oracle.DataAccess.dll

Sure enough, I look at the exception details in the debugger and I see the following information (this occurs when I attempt to create a new ORACLE connection):


"The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception." InnerException {"The provider is not compatible with the version of Oracle client"} System.Exception {Oracle.DataAccess.Client.OracleException}

A Little Background:

I'm basically migrating my data layer to a WCF service. The same service layer previously existed in a WinForm application. Everything works fine in my WinForm application. I include the same reference to the Oracle.DataAccess.dll and all my reads/writes with the database work fine.

Is there something obviously different between the WCF and WinForm access/use of the DLL? Is there some limitation I'm unaware of? Is there an issue running this through VS2010 in the debugger?

I have absolutely no idea what is going on here. Any hints/direction would be greatly appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 19 2012
Added on Aug 21 2012
5 comments
1,653 views