Connecting to an Oracle database without installing an Oracle client software package on the server/client deployment environment:
Some application deployments to clients or servers require database connections to Oracle instances. What happens when the deployment environment doesn’t have the Oracle client software loaded? What if the server configurations are not accessible, or it takes an act of congress to install anything to the environment?
In this example I am adding ‘instant client’ support to a .net application using the ODP.NET driver but other drivers can leverage the instant client. Also, I am using the latest ODP.NET driver for the .NET 4 framework, as it supports the Entity framework =)
Required software -
- Oracle Instant Client
- Oracle ODP.NET (or your preferred Oracles driver that is supported by Instant Client)
http://www.oracle.com/technetwork/indexes/downloads/index.html
In your .net application, add the following 5 DLLs (from the Oracle download) to the root directory of your project and configure the properties of each to ‘Copy if newer’.
- ODP.NET Drivers
- OraOps11w.dll
- Oracle.DataAccess.dll (if this is in your ref folder, set the property to ‘Copy Locally’
- Instant Client Files (Depending on the version you downloaded, you only need one set)
- Basic
- oci.dll
- orannzsbb11.dll
- oraociei11.dll (111M)
- Light
- oci.dll
- orannzsbb11.dll
- oraociicus11.dll (~31M)
If you are using Entities or need access to the factory in ODP.NET, you’ll need to register the provider in the web.config (*check the version of your driver to be sure it matches) -
<system.data> <DbProviderFactories> <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.112.2.30, PublicKeyToken=89b483f429c47342" /> </DbProviderFactories> </system.data>
When you build/deploy your application, the 5 DLLs should be in the web app bin folder, or if you are building a client app – they should be in the same folder as the exe.
References -
Good tutorial with screen shots (http://alderprogs.blogspot.com/2009/04/deploying-odpnet-with-oracle-instant.html)
Oracle’s Developer Guide (http://download.oracle.com/docs/html/E10927_01/InstallODP.htm)
Jeremy, this is some good info that I know I will put to pratice.
[...] Oracle Instant Client with ODP.NET (jeremybranham.wordpress.com) [...]
This did not work for me. Strangely, I’ve successfully used these steps in other projects without the entity framework but in this case, I wanted to use it. Instantiation of my entity context fails:
FRTREntityContext context = new FRTREntityContext();
Stack Trace:
[OracleException (0x80004005): The provider is not compatible with the version of Oracle client]
Oracle.DataAccess.Client.OracleInit.Initialize() +356
Oracle.DataAccess.Client.OracleClientFactory..cctor() +50
[TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.]
well, i made some minor changes in the web.config that must have restarted the application pool and it appears to be working now. Thanks for your post, the more people that document this method clearly the less time it will take to look it up next time
Thanks Adam!
Thanks for sharing this. The bit about adding the factory to config was priceless. Every other resource on the web want you to modify the machine.config. Again, thanks!
Thanks Doug. Modifying the machine.config was not an option for me either.