开发者

Oracle.DataAccess.dll not loading using C#

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 sti开发者_如何学Pythonll trying to figure out what exactly is wrong in this case.


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.


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.


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


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?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜