Oracle.DataAccess.dll typeinitialization error when running in IIS

I have created a WCF project in VS 2012 which connects to an Oracle 10g db using the Oracle 11.2.0 (32bit) ODP.NET drivers. The Oracle client is fully installed on my machine (its a DEV server with VS tools installed on it). I am able to connect to Oracle via ODBC and also via the code I have written to use ODP.NET - while it runs in VS 2012.

All is fine, until I try to deploy to the web server ...

On the same machine, I have deployed the project to a folder and hosted that folder in IIS as a web-application which allows 32bit applications to run.

When I try to execute the project under IIS I get the following error message:
"The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception." (there is no inner exception).

I have spent a LOT of time reading and trying various tips. Here are the facts:

1. The Oracle Client is installed and running fine on the machine
2. ORACLE_HOME=C:\oracle
3. My PATH starts with: C:\oracle\bin;C:\oracle
4. I am referencing Oracle.DataAccess.dll from C:\Oracle\\bin\4
5. I have copied the following files into the destination BIN folder:
       oci.dll (v11.2.0.1)
       Oracle.DataAccess.dll (v4.112.3.0)
       oraociel11.dll (v11.2.0.1)
       OraOps11w.dll (v2.112.3.0) - I cannot see any other versions
6. My registry entry: HKLM\SOFTWARE\ORACLE\ODP.NET\ has a DllPath=C:\Oracle\\bin\4 - I have no other ORACLE registry entries at that level.

7. I have tried OleDb and the deprecated MS Oracle drivers and they caused even more issues and wouldn't work in dev mode (vs 2012) so I do NOT want to attempt that again.

So my overarching question is: why on the SAME machine can I run this successfully in VS 2012 but NOT when I deploy to IIS??

I need some fresh ideas and a detailed step-by-step on how to make this work as I am pulling my hair out. Why does Oracle have to make it so difficult to interact with .NET???!

:-) any help would be most appreciated!

Who is Participating?
Bob LearnedConnect With a Mentor Commented:
You might want to try the fully managed client for .NET.  It is a single file, Oracle.ManagedDataAccess.dll, and doesn't depend on any installed client files.  You can also deploy your application to the web server with the TNSnames.ora entry in the web.config file.

Mark GeerlingsDatabase AdministratorCommented:
"Why does Oracle have to make it so difficult to interact with .NET???!"

Maybe because Larry Ellison is jealous of Bill Gates because Bill's net worth is higher than Larry's?

That's not a technical answer, it's just my guess.  But, Oracle certainly does not make cooperating with Microsoft products easy.
designavenueAuthor Commented:
Hi guys thanks for the notes!

I ended up ripping everything out and just installing the ODP.NET driver. Works like a charm now!


PS 12c does not work with db version 10g. Just FYI.
designavenueAuthor Commented:
12c doesn't work with db version 10g. But otherwise - great suggestion!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.