Monday, December 16, 2013

How do I get Oracle to work with ASP.NET?

I can say that Oracle and .NET is a real pain to get working.  Here are some things that took me a while to learn:

The Oracle Drivers are un-managed

Although Oracle has an xCopy version of the drivers, there are still un-managed pieces of the driver.  What that means, is that you will need to do a full install of the drivers both on your development machine and the server. 

The Oracle Drivers are either 32bit or 64bit

Install the drivers that are appropriate for your web server, either 32 bit or 64 bit.  You will also need to have the app pool for the application set to either 32 bit or 64 bit.   If you don’t, you will receive this dreaded 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.

Download the Oracle Drivers
Look for the Oracle Data Access Components (ODP.NET) on this link.

Driver Reference
Add a reference to the Oracle.DataAccess
Check if the references if the Oracle.DataAccess is marked to Copy local.

Visual Studio 2010 and earlier have 32 bit Casini

When you run the web application inside Visual Studio, the default web server built into Visual Studio is called Casini.  It is 32 bit.  So although you may have a 64 bit machine and 64 bit drivers, Oracle will not run in Visual Studio unless you get the 64 bit Casini version.  Visual Studio 2012 and higher has a Casini that is 64 bit.  It is interesting to note that any MSTest or NUnit tests will be run in 64 bit mode so any integration tests will work.

No comments: