Posts Tagged ‘64 bit’

Running 32 bit Windows Service in 64 bit environment and related Oracle issue

June 19, 2008

Recently, I had to install a Windows service in a machine running the 64 bit Windows server 2003. I compiled the service and installed it successfully in the target machine.

When I ran the service and the service tried to connect to Oracle, I got the following error:

System.IO.FileNotFoundException: Could not load file or assembly ‘Oracle.DataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342’ or one of its dependencies. The system cannot find the file specified.
File name: ‘Oracle.DataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342’

I checked and found that the correct version of Oracle DataAccess provider was installed on the machine. I suspected that it might be some permissions issue and tried explicitly setting permissions on the Oracle folder. That did not help. I then thought it might be some bad install of Oracle DataAccess provider and re-installed it. I still got the same error mentioned above.

Finally, I found the problem:

When I compiled the service application, I had used the default compilation option, which was to target any CPU.

Advanced Compiler Options

When ‘AnyCPU’ is specified for the Target CPU, the service will run in 64 bit mode in a 64 bit OS. I had installed only the 32 bit Oracle DataAccess provider on the machine. The service was running in 64 bit mode and trying to load the 64 bit Oracle DataAccess provider DLL and not finding it.

I re-compiled the application and selected ‘X86’ for the Target CPU and published it to the server.

Voila!!! No more Oracle errors.