I am trying to run this web application. I keep getting this error "Could not load file or assembly "Oracle.DataAccess" or one of its dependencies. An attempt was made to load a program with an incorrect format." Exception details: System.BadImageFormatException. "Could not load file or assembly "Oracle.DataAccess" or one of its dependencies. An attempt was made to load a program with an incorrect format." Below are the things that I already tried.
1) replaced all the oracle dll's with 32 bit oracle dll i.e 2.112.3.0
I have 32 bit client installed on 64 bit machine. The operating system is windows 7.
2) compile each individual project individually. Deleted all the oracle dependent files dll and then added the 2.112.3.0 dll's individually and then compiled each project
3) Register the 32 bit dll on GAC using this statement gacutil /i %ORA_HOME4%\odp.net\bin\4\Oracle.DataAccess.dll
gacutil /i %ORA_HOME4%\asp.net\bin\4\oracle.web.dll
for the above two statements, I copied the gacutil.exe from c:\Program Files(x86)\Microsoft sdk\windows\v7.0A\Bin\NETFX4.0 Tools\X64 to C:\ drive and then
I executed the above two statement:
gacutil /i %ORA_HOME4%\odp.net\bin\4\Oracle.DataAccess.dll gacutil /i %ORA_HOME4%\asp.net\bin\4\oracle.web.dll when I executed the above two statements, I didn't get any message, I executed them in Dos windows under administrator privilege.
4) I also deleted all the Temporary ASP.net files from this location
c:\windows\Microsoft.Net\V4.0.30319\temporary ASP.net files I also changed the web application build Platform target to X86, Originally, it was at "ANy CPU". out of frustration, I also tried changing the platform target to X64 and then I got the error message saying
" Cold not load file or assemble . webapp" or one of its dependencies. An attempt was made to load a program with an incorrect format.
I don't have IIS installed on my computer, I am running this application in visual studio 2010 so I think it will be using the inbuilt IIS that comes with visual studio.
I spend lot of hours resolving this issue, but still getting the same error again and again.
any help or hint will be highly appreciated.
This question is related to
visual-studio-2010
iis
oracle11g
If you are using IIS Express and VS 2017:
Go to the Web Application Properties > Web Tab > Servers Section > And change the Bitness to x64.
In my case, I use VS 2010, Oracle v11 64 bits. I might to publish in 64 bit mode (Setting to "Any Cpu" mode in Web Project configuration) and I might set IIS on Production Server to 32 Bit compability to false (because the the server is 64 bit and I like to take advantage it).
Then to solve the problem "Could not load file or assembly 'Oracle.DataAccess'":
Also you can download and execute the install.bat file in 'ODAC112030Xcopy.zip' from 64-bit Oracle Data Access Components (ODAC) Downloads. This resolved my problem.
i Have face the same issue and resolved by replacing the old Oracle.DataAccess.dll with new Oracle.DataAccess.dll(which come with oracle client when install)
in my case the path of new Oracle.DataAccess.dll is
Try this: Open IIS Manager, change application pool's advance setting, change Enable 32 bit Application to false.
In my case the following solved the problem:
oracle.dataaccess.dll
to the bin
file by browsing the file location or just from the refence list in .NET
tab.You may need to enable 32-bit applications in your AppPool. Go to > 'Application Pool' in IIS => right click your app pool => advance setting => 'enable 32 bit application' to true.
Please don't forget to restart your app pool and your corresponding application pointing to that app pool.
For me everything else was almost ok, but somehow my project settings changed & iisExpress was getting used instead of IISLocal. When I changed & pointed to the virtual directory (in IISLocal), it stared working perfectly again.
In my case I had a console application, I just unchecked Prefer 32-bit on Build projet properties tab and then I add this to my app.config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="2.112.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I needed a 64-bit version of oracle.dataaccess.dll but this caused problems with other libraries I was using.
[BadImageFormatException: Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
I followed several steps above. Going to advance settings on the projects pool to toggle allow 32bit worked but I wasn't content to leave it like that so i turned it back on.
My project also had references that relied on Elmah and log4net references. I downloaded the latest version of these and my project was able to build and run fine without messing with the pools's allow 32bit setting.
I had the same error with Oracle.DataAccess
but deploying to Azure Web Sites (azurewebsites.net). For me I had to edit a setting in VS.NET 2019 before publishing to Azure. I ticked the checkbox "Use the 64 bit version of IIS Express for Web sites and projects" which is found under Tools > Options > Projects and Solutions > Web Projects
.
I found the solution with following steps:
Oracle.DataAcces.dll
reference,C:\windows\assembly\GAC\Oracle.DataAccess\X.XXX.X.XX__89b483f429c47342/oracle.dataaccess.dll
Hope it helps
Source: Stackoverflow.com