Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
my project is working fine on localhost but when i am running on server its show me this error.
is there something to add in webconfig file?


XML
<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <!--<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>-->
    <add name="connectionString" connectionString="User Id=RBSS;Password=RBSS;Data Source=ORCL;" providerName="System.Data.OracleClient"/>
  </connectionStrings>
  <appSettings>
    <add key="connectionString"  value="User Id=RBSS;Password=RBSS;Data Source=ORCL;"/>
  </appSettings>
  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">

    </compilation>

    <customErrors mode="Off"/>
    <authentication mode="Windows">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
    </authentication>

    <pages enableEventValidation="false" validateRequest="false"/>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
  <runtime>
    <!--<assemblyBinding registervalue="1">

    </assemblyBinding>-->
  </runtime>
</configuration>
Posted

The "incorrect format" is pointing to that you have a 32 bit oracle client on a 64 bit server or that you're running the application pool in 32 bit mode with a 64 bit client.

Try to open your IIS Manager and click on "Application Pools" in the left pane.
Right click the application pool your site is using and select "Advanced Settings..."

In the window that pops up under "General" you have "Enable 32-Bit Applications".
Toggle that setting. and restart the application pool.

If it works after this you should consider installing the correct client.
Mind that there are acceptable reasons to run your application with the wrong Bitness.
 
Share this answer
 
Comments
Espen Harlinn 2-Mar-13 16:32pm    
Good reply, Jörgen - I've seen this before, and your solution is usually the correct one ...
Jörgen Andersson 2-Mar-13 17:02pm    
Been there, done that.
my project is working fine on localhost but when i am running on server its show me this error.
Because your local system might have the Oracle installed on it thus having access to assembly 'Oracle.DataAccess'(most probably it will be in GAC). Your server might not have this and thus the error.

You need to make sure that all the needed filed to connect Oracle is present on server too.
 
Share this answer
 
If running in a 64 bits server with 64 bits Oracle client, I could make it work adding the reference to C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Data.OracleClient.dll, setting copy local true and running the IIS application pool with Enable 32-bits=False.

Thanks!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900