5

I am having a problem on loading oracle.dataaccess. Here's the message I get:

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.

I have following entries in my web.config for this.

<add assembly="Oracle.DataAccess, Version=2.112.1.0, Culture=neutral,
  PublicKeyToken=89b483f429c47342"/>

Under assemblies

and

<dependentAssembly>
  <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342"
    Culture="neutral" />
  <BindingRedirect oldVersion = "2.112.1.2" newVersion = "2.112.1.0" />
</dependentAssembly>**

I am developing on Visual Studio 2008 on a Windows Vista machine. I have my IIS 7.0 application pool enabled for 32-bit applications, and my platform target for this project is x86 instead of 'Any CPU'.

I am still trying to figure out what exactly is wrong in this case.

1
  • 2
    What was the final outcome of this? How did you finally connect to Oracle? Did you give up and ask the Oracle DB owner to send a nightly extract like everyone else does? Commented Jul 6, 2012 at 18:11

6 Answers 6

3

It seems like the problem is that you have 64-bit client installed, which will not be recognized by Visual Studio because it is a 32-bit app. Unfortunately, the best solution I've found is to install both the 32-bit and the 64-bit clients on the same machine. I install one in C:\Oracle\11gClient32 and the other in C:\Oracle\11gClient64. You should install the 32-bit version first, followed by the 64-bit version.

Keep in mind that you will need to maintain two copies of sqlnet.ora and tnsnames.ora (or ldap.ora) in the [oracle]\network\admin folder.

Sign up to request clarification or add additional context in comments.

Comments

2

The Oracle.DataAccess assembly exists in a 32-bit and a 64-bit version. Check the bitness of the assembly your project is referencing, it must be 32-bit for a 32-bit (x86) app.

1 Comment

Oracle 11g for 64 bit is installed on my dev. machine. So I took oracle.dataAccess.dll from this path on my local machine. E:\oracle\ora11r2\ODP.NET\bin\2.x. I had my vs 2008 project platform target set as "Any CPU" so it can work with both 32/64 bit. I have added oracle.dataAccess.dll from path i mentioned above. so if there anything I am doing wrong ?
1

Make sure that you install the Oracle Client software to the machine. Simply referencing Oracle.DataAccess doesn't work out of the box. ODAC

5 Comments

Oracle 11g for 64 bit is installed on my dev. machine. So I took oracle.dataAccess.dll from this path on my local machine. E:\oracle\ora11r2\ODP.NET\bin\2.x. I had my vs 2008 project platform target set as "Any CPU" so it can work with both 32/64 bit. I have added oracle.dataAccess.dll from path i mentioned above. so if there anything I am doing wrong ?
I wouldn't advise to copy the DLL into your project. Use the assembly in the Global Assembly cache that was installed by oracle client.
I tried doing that. But, when I try to add a reference on my project, Oracle.DataAccess is not even showing up. Weirdly Oracle.Web is showing up in 'Add Reference' dialouge box. does that mean that oracle installation on my machine is not done properly. Plus, when i look in my assembly 'C:\Windows\assembly' oracle.DataAccess does show up over there. so i am still not sure what's exacly is wrong. Thank you so much for giving some insight over this problem.
Sometimes you have to wait a minute or so before all references load into the "Add Reference" dialog in visual studio. Also, are you using .net 3.5 or 4? If so, you need to be sure you have the ODAC that is compatable with the latest versions of .net, otherwise show references will not show Oracle.DataAccess. Which version of .net are you running for this project?
thanks very much for your help. i use 3.5. my odac is also compatible. i think that i need to uninstall everything regarding oracle and install it again on clean slate. but your replies helped me a lot.
0

Are you sure you have added the assembly at all? Also...sure about the token? And finally...sure about the 32/64 compatibility as the guy above suggested?

1 Comment

Oracle 11g for 64 bit is installed on my dev. machine. So I took oracle.dataAccess.dll from this path on my local machine. E:\oracle\ora11r2\ODP.NET\bin\2.x. I had my vs 2008 project platform target set as "Any CPU" so it can work with both 32/64 bit. I have added oracle.dataAccess.dll from path i mentioned above. so if there anything I am doing wrong ?
0

I too had similar issue and I was getting the below error:

Unhandled exception: System.BadImageFormatException: 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.

It was working properly in my local system, where I had 32-bit and 64-bit versions of the dll were installed. But in the server, only 64-bit version was installed and I was not allowed to make any installation.

So followed these steps:

1)The project reference pointed to OracleDataAccess.dll , version 64 bit.
2)In the project properties -> Build -> Platform target : x64. So when you 
select x64, Prefer 32-bit option would be unchecked automatically. Then I 
did re-build of the project and deployed. 

Finally I could connect to oracle database successfully.

Comments

-2

In case it is a 64 bit issue, you may try changing the target CPU to x86 (Project Properties - Compile Tab - Advanced Compile Options - Target CPU) and recompiling.
This did the trick for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.