简体   繁体   中英

ODP.NET 32 bit on Win 7 64 bit and Win Server 2003 64 bit

I have a .NET winforms application which uses ODP for connection to oracle db. ODP installation is 32 bit i'm developing the aplication on a Win 7 64 bit machine . I'm setting the platform target as x86 on the development machine and it runs ok. But when i tested the application on Win Server 2003 64 bit machine it gave the exception

The type initializer for 'Oracle.DataAccess.Client.OracleCommand' threw an exception.                                            

UNHANDLED EXCEPTION STACK TRACE:at Oracle.DataAccess.Client.OracleCommand.Dispose(Boolean disposing) 
at System.ComponentModel.Component.Finalize()

UNHANDLED EXCEPTION SOURCE: Oracle.DataAccess

UNHANDLED EXCEPTION INNER EXCEPTION: Oracle.DataAccess.Client.OracleException The provider is not compatible with the version of Oracle client    at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleCommand..cctor()

UNHANDLED EXCEPTION DATA: System.Collections.ListDictionaryInternal

UNHANDLED EXCEPTION MESSAGE: The type initializer for 'Oracle.DataAccess.Client.OracleCommand' threw an exception.

And when i set the platform target to Any CPU on Windows 7 64 bit it gives the exception:

Could not load file or assembly 'Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. An attempt was made to load a program with an incorrect format.

ODP version on development machine(Win 7 64 bit) is 11.2.0 and on the test machine(Win Server 2003 64 bit) is also 11.2.0

What should i do to run the application on both machines? Any idea?

IMO There are a few options:

  1. Compile for x86 and install the 32 bit Oracle Client on your 64bit server (could run side by side if you change the ORACLE_HOME, TNS_ADMIN, ... system variables);
  2. Compile for x86 and pack all DLL's for a 32 bit Oracle Instant Client together with your binaries (make sure the TNS_ADMIN system variable is set otherwise you won't be able to use LDAP or tnsnames);
  3. Compile your application for Any CPU but create a different set of dll's for x64 and x86 bit (Oracle.DataAcess.dll is compiled for a specific architecture, there is a version for x64 and one for x86);
  4. Oracle is working on a managed Oracle driver , no Oracle client is required anymore, most codebases can converted easily but be aware that it's not feature complete yet and only supports Oracle 11+ databases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM