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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.
Bob LearnedCommented:
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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.