Problem: Website throws error "System.Data.OracleClient requires Oracle client software version 8.1.7 or greater" on live/production server. In my case, my hosting server did not allow me to install Oracle client, so what to do?
Impact: The website uses an Oracle database for the content so this error makes the website entirely inaccessible.
Solution:
Upon contacting my hosting company I was told that it was not possible to install the Oracle client software on the server, so I started to look around for the minimum requirements needed to access Oracle. I found one thread on Stack Overflow regarding the minimum requirements for ODP.NET. One of the posters, wrote that the smallest number of files needed to access Oracle were:
- OCI.dll
- Oracle.DataAccess.dll
- OraOCIEI11.dll
- OraOps11w.dll
Note: I found that, instead of OraOCIEI11.dll, you could replace it with the file oraociicus11.dll taken from the Oracle basic lite instant client. This file is 33.7 MB, significantly reducing the footprint of your website.
Here's how to connect to Oracle without installing the client:
- Download the basic lite version of Oracle instant client, which you can find on the Oracle website. (I downloaded the 11.2 version.)
- Create a 'bin' folder in your website if you don't already have one. (Right-click the root of your website in the Solution Explorer, choose 'Add ASP.NET Folder,' and then select 'Bin.')
- Unzip the version of Oracle instant client that was downloaded in step 1.
- Look for the following files in your Oracle client folder and copy it to your website's 'bin' folder: OCI.dll, Oracle.DataAccess.dll,
OraOCIEI11.dlloraociicus11.dll, and OraOps11w.dll. - There is still more to do, however. You need a way to let your application/website know that it should look in the 'bin' folder. Add a Global Application class if you don't have one. (Right-click website root in the Solution Explorer > 'Add New Item' > 'Global Application Class.') If you haven't renamed the file, you should now have a file called Global.asax in your website folder.
- Open your Global.asax file and add the following two lines within your Application_Start() function (find more ways to load assembly files here):
String _path = String.Concat(System.Environment.GetEnvironmentVariable("PATH"), ";", System.AppDomain.CurrentDomain.RelativeSearchPath);
System.Environment.SetEnvironmentVariable("PATH", _path, EnvironmentVariableTarget.Process); - Now, upload these DLL files and Global.asax file to your server if you haven't already. Congratulations! Your website should now be able to connect to Oracle.
0 comments:
Post a Comment