When you compile your DLL with "x86" then also the Oracle.DataAccess.dll
must be the x86 version (i.e. 32 bit version)
When you compile your DLL with "x64" then also the Oracle.DataAccess.dll
must be the x64 version (i.e. 64 bit version)
For "AnyCPU" it depends, there is no "AnyCPU" version of Oracle.DataAccess.dll
. If your application runs on 64-bit Windows it will run as x64 process - thus also Oracle.DataAccess.dll
must be the x64 version. If your application runs on 32-bit Windows it will run as x86 process - thus also Oracle.DataAccess.dll
must be the x86 version.
To cut a long story short: architecture of Oracle.DataAccess.dll
must be the same as the application, i.e. your DLL.
Follow this instruction to run both in parallel:
BadImageFormatException. This will occur when running in 64 bit mode with the 32 bit Oracle client components installed
Update
In your *.csproj
, resp. *.vbproj
edit your reference to ODP.NET like this:
<Reference Include="Oracle.DataAccess">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
Attributes like Version=...
or processorArchitecture=...
are not required. Your application will load the correct Oracle.DataAccess.dll
depending on selected architecture and target .NET framework (provided that it is installed properly)