Error using oracle.dataaccess.dll
I have a web application which uses Oracle.DataAccess.dll to communicate with an Oracle db. The web application deployed on 32 bit windows system works but not on windows server 2008 64 bit. I installed 10204_vista_win2k8_x64_production_db package, referenced the installed dll (version 2.102.4.0) from the project but I get the following error:
Could not load file or assembly 'Oracle.DataAccess开发者_StackOverflow社区, Version=2.102.4.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
Same here. The Oracle.DataAccess assembly doesn't run in 64 bit mode.
You should set the application pool for your site to 32 bit mode (go to the application pool's Advanced Settings and set Allow 32 Bit Applications to "True")
If that doesn't work, make sure your Oracle directory (the directory containing all the Oracle dlls) is in your system path. If you forget that, you get the same cryptic error about not finding Oracle.DataAccess.
EDIT:
Installing the Oracle client can be a major pain. Using the Oracle Instant Client is somewhat easier than installing the full client, so this is what I usually do:
- Download the Oracle Instant Client
- Unzip the archive in c:\oracle (any other directory will do)
- Open a command prompt as administrator
- type cd \oracle
- type configure odp.net20 myhome
- Right-click on "My Computer", "Advanced System Settings", "Environment Variables" and add the C:\oracle directory to the system path
- Copy the Oracle.DataAccess.dll file from c:\oracle\odp.net\bin\2.x to your application's bin folder
- (optonally) edit your c:\oracle\tnsnames.ora file
I'm going to give you the answers from what I've just went through on Windows Server 2008 R2 which is a 64 bit operating system. The application suite of libraries I was given were developed using .net 3.5 x86 with the older DLL libraries and I was stuck because I had installed the newer x64 clients from oracle.
What I found was the following: Install the latest x64 client from Oracle for Windows Server 2008. I believe this would be the 2.7.0 client. When you select the installation, make sure you do custom and select the .NET libraries. Configure your tnsnames files and test your tnsping against your data source.
Next, if you are running a 32 bit application, install the same version of the client for 32 bit. Also, follow the same installation routine, and select the same home.
When your finished, you will find that you have a single app/product with two client directories (Client1 and Client2).
if you navigate to the windows/assemblies directory you will find that you have a reference to the Oracle.DataAccess.dll (x2) with one for x86 and one for AMD64.
Now, depending on if you have developers or are developing on the machine yourself, you may be ok here, however, if they are using older drivers, then you need to perform one last step.
Navigate to the app\name\product\version\client_1\odp.net\publisher policy\2.x directory. Included in here are two policy files. use gacutil /i to install the Policy.2.111.Oracle.DataAccess.dll into the GAC. This will redirect legacy oracle ODP calls to the newer versions. So, if someone developed with the 10g client, it will now work with the 11 client.
If you need further details, or need other questions answered like flipping 32 bit mode on or off on your .net assemblies, email me.
J Banks jbanks27@hotmail.com
Good luck.
If you can't have 32 bit oracle client working and installed 64 bit, you will need to install the 64 bit client, and grab the oracle.dataaccess.dll file under odp.net from the oracle client installed folder. And you have to use this dll and exchange the reference to this file instead of using 32 bit dll.( which is what you probably have for the project/solution)
If you have different bit of oracle client it's not going to work. so you will get errors like that. Hope that helps.
See illustration on Implementing Oracle.Web.dll, Oracle.DataAccess.dll 64-bit failed on Windows Server 2008 with IIS 7.5 32-bit disabled
If you're using the 32-bit version of Oracle.DataAccess.dll then you need to do one of the following:
a) Deploy to a 32-bit server, or
b) Deploy to a 64-bit server with 'Enable 32-bit applications' set to 'true'.
If you're using the 64-bit version of Oracle.DataAccess.dll then you simply have to use a 64-bit server.
The problem is caused by Oracle as the don't offer an AnyCPU version of Oracle.DataAccess.dll (probably because it has unmanaged/native portions)
If you do the following, everything works fine 1. Consistently set all your dlls to AnyCPU. 2. Make sure that the appropriate version of the dll is installed on the machine on which the executable will be run (i.e. 32 bit or 64 bit i.e. same as OS) 3. Ignore compiler warnings that the a 64/32 bit version is being used rather than an MSIL version
The compiled versions can then be used on both 32 and 64 bit as long as the appropriate version of the oracle dll is installed.
精彩评论