locked
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. RRS feed

  • Question

  • User154870787 posted

    Hi,

    I have a vs2008 web application. it built fine and it was runing fine use visual studio development server, but when i use IIS web server, it gave me the following error, Can you anybody help with that? Thanks.

     

     

    Server Error in '/Vendorapplication' Application. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>


    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. <o:p></o:p>

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    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.

    Source Error: <o:p></o:p>

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. <o:p></o:p>


    Assembly Load Trace: The following information can be helpful to determine why the assembly 'Oracle.DataAccess' could not be loaded.<o:p></o:p>

    <o:p> </o:p>

    === Pre-bind state information ===<o:p></o:p>

    LOG: User = IIS APPPOOL\Vendorapplication<o:p></o:p>

    LOG: DisplayName = Oracle.DataAccess<o:p></o:p>

    (Partial)<o:p></o:p>

    LOG: Appbase = file:///C:/Vendorapplication/Vendorapplication/<o:p></o:p>

    LOG: Initial PrivatePath = C:\Vendorapplication\Vendorapplication\bin<o:p></o:p>

    Calling assembly : (Unknown).<o:p></o:p>

    ===<o:p></o:p>

    LOG: This bind starts in default load context.<o:p></o:p>

    LOG: Using application configuration file: C:\Vendorapplication\Vendorapplication\web.config<o:p></o:p>

    LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config<o:p></o:p>

    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.<o:p></o:p>

    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).<o:p></o:p>

    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/vendorapplication/8cc1d433/257b7ed7/Oracle.DataAccess.DLL.<o:p></o:p>

    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/vendorapplication/8cc1d433/257b7ed7/Oracle.DataAccess/Oracle.DataAccess.DLL.<o:p></o:p>

    LOG: Attempting download of new URL file:///C:/Vendorapplication/Vendorapplication/bin/Oracle.DataAccess.DLL.<o:p></o:p>

    ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.<o:p></o:p>


    Stack Trace: <o:p></o:p>

    <o:p> </o:p>

    [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.]<o:p></o:p>

       System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0<o:p></o:p>

       System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +416<o:p></o:p>

       System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +166<o:p></o:p>

       System.Reflection.Assembly.Load(String assemblyString) +35<o:p></o:p>

       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190<o:p></o:p>

    <o:p> </o:p>

    [ConfigurationErrorsException: 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.]<o:p></o:p>

       System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11211672<o:p></o:p>

       System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +388<o:p></o:p>

       System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +232<o:p></o:p>

       System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48<o:p></o:p>

       System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +210<o:p></o:p>

       System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +191<o:p></o:p>

       System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +54<o:p></o:p>

       System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +295<o:p></o:p>

       System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +476<o:p></o:p>

       System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +116<o:p></o:p>

       System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +175<o:p></o:p>

       System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +52<o:p></o:p>

       System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +50<o:p></o:p>

       System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +425<o:p></o:p>

       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +263<o:p></o:p>

    <o:p> </o:p>


    Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

     <IFRAME style="WIDTH: 100%; HEIGHT: 246px" id=ctl00_ctl00_bcr_bcr_PostForm_ctl04_PostBody_ctl00_Editor_ifr src='javascript:""' frameBorder=0></IFRAME>

    Friday, January 28, 2011 7:47 PM

Answers

  • User269602965 posted

     Okay, I have some recommendations.  The key to success with Oracle in DEV environment is proper installation on a static IP address, resolving firewall issues, and having the right clients installed for IIS, VStudio, and other applications, like TOAD for Oracle.

    1.  Oracle works best on a static (never changes) IP address as per the Windows installation guide and personal experience, and Oracle recommends using the Microsoft Loopback Adapter, a virtual LAN adapter, for hosting Oracle in your development environment.  In that case, the virtual static IP becomes something you choose, like 192.168.50.50, a local address, and the localhost 127.0.0.1 becomes the DNS address (Gateway Address not required).  The advantage of this setup is if anything changes on your wired or wireless LAN adapters, Oracle is unaffected.

    http://download.oracle.com/docs/cd/E11882_01/install.112/e16773.pdf is the Windows Installation Guide for Oracle.

    You would have to uninstall Oracle, reboot, remove Oracle Key from Registry HKEYLOCAMACHINE > Software > Oracle key, install the Loopback Adapter, temporarily disable you wired and wireless LAN adapters, reinstall Oracle on the Loopback Adapter static IP only, complete the additional Windows Oracle installation tasks.

    2.  Since you are running 64-bit OS and likely installed the 64-bit database, after getting Oracle reinstalled on a static IP on the Loopback Adapter, I would also download the ODP.NET 32-bit with Client and VS Tools, and install in another Oracle Home directory, so yes, you have both 64-bit and 32-bit Oracle clients available.  With the 32-bit Oracle client running, many problems with VS Tools, TOAD, IIS go away.

    3.  Windows 7 has a two-way software firewall.  You can create INBOUND and OUTBOUND firewall rules to deny or allow traffic on various TCP ports.  When Oracle is installed on the Loopback Adapter, it is listening on default TCP port 1521 for traffic from your wired LAN adapter to the virtual LAN Loopback Adapter.  So, you can create a firewall rule to allow TCP 1521 port traffic between these IP addresses or ranges of IP addresses.  As I recall, this issue is discussed in the Oracle Install Guide for windows as well.

    I had some notes on installing Oracle on Windows, but at the moment, cannot find the TEXT file.

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 31, 2011 10:45 PM

All replies

  • User-693248168 posted

    Did you copy all the Dlls after you build your application in Visual studio to your bin folder in IIS virtual directory?

    Saturday, January 29, 2011 6:35 AM
  • User269602965 posted

     IIS Server needs ODP.NET Oracle Client installed, same version as that used in production database.

     

    Saturday, January 29, 2011 5:43 PM
  • User154870787 posted

     The oracle is installed. Like i said it works using visual studio development server. It is not working using IIS server(it is also  on my local development machine, so it local IIS server,not production).

    Sunday, January 30, 2011 1:04 PM
  • User154870787 posted

     It is on the same server(on my development machine). there is no need to copy. I mean it works using the visual studio development server, it was not working on the IIS server on the same machine.

    Sunday, January 30, 2011 1:05 PM
  • User269602965 posted

    Show us you web.config CONNECTION STRING to Oracle. 

    If using Windows 7, Windows 2003/2008, did you make an INBOUND firewall rule for Oracle listener PORT (default port is 1521)?

    Sunday, January 30, 2011 1:22 PM
  • User269602965 posted

    Give us some specific information.

    What is your operating system?

    Are you working in 32-bit or 64-bit?

    What version of IIS are you using?

    What version of Oracle database is installed on the machine?

    What version of ODP.NET did you install?

    Are you developing in ASP.NET 2.0/3.5 or ASP.NET 4.0?

    That makes a difference because oracle uses different versions of oracle.dataaccess.dll for each version of ASP.NET.

    Go to your database home direction > ODP.NET > bin and copy the correct version of oracle.dataaccess.dll

    to your ASP.NET project BIN folder, and redo you references to be local to the BIN folder of project

    and not the GAC.

     

    Sunday, January 30, 2011 1:31 PM
  • User154870787 posted

     I am using localhost.

    Monday, January 31, 2011 12:14 AM
  • User154870787 posted

     what is  INBOUND firewall rule, i am using

    windows 7,64 bit,  IIS7, vs2008(framework 2),oracle 11g. The odd thing is everything works fine using visual studio development server, so all the oracle data access should be no problem. what is the difference between using visual studio development server and iis server?

    Monday, January 31, 2011 12:19 AM
  • User154870787 posted

     what do you mean by "make an INBOUND firewall rule for Oracle listener PORT "? Thanks.

    Monday, January 31, 2011 12:20 AM
  • User269602965 posted

     Okay, I have some recommendations.  The key to success with Oracle in DEV environment is proper installation on a static IP address, resolving firewall issues, and having the right clients installed for IIS, VStudio, and other applications, like TOAD for Oracle.

    1.  Oracle works best on a static (never changes) IP address as per the Windows installation guide and personal experience, and Oracle recommends using the Microsoft Loopback Adapter, a virtual LAN adapter, for hosting Oracle in your development environment.  In that case, the virtual static IP becomes something you choose, like 192.168.50.50, a local address, and the localhost 127.0.0.1 becomes the DNS address (Gateway Address not required).  The advantage of this setup is if anything changes on your wired or wireless LAN adapters, Oracle is unaffected.

    http://download.oracle.com/docs/cd/E11882_01/install.112/e16773.pdf is the Windows Installation Guide for Oracle.

    You would have to uninstall Oracle, reboot, remove Oracle Key from Registry HKEYLOCAMACHINE > Software > Oracle key, install the Loopback Adapter, temporarily disable you wired and wireless LAN adapters, reinstall Oracle on the Loopback Adapter static IP only, complete the additional Windows Oracle installation tasks.

    2.  Since you are running 64-bit OS and likely installed the 64-bit database, after getting Oracle reinstalled on a static IP on the Loopback Adapter, I would also download the ODP.NET 32-bit with Client and VS Tools, and install in another Oracle Home directory, so yes, you have both 64-bit and 32-bit Oracle clients available.  With the 32-bit Oracle client running, many problems with VS Tools, TOAD, IIS go away.

    3.  Windows 7 has a two-way software firewall.  You can create INBOUND and OUTBOUND firewall rules to deny or allow traffic on various TCP ports.  When Oracle is installed on the Loopback Adapter, it is listening on default TCP port 1521 for traffic from your wired LAN adapter to the virtual LAN Loopback Adapter.  So, you can create a firewall rule to allow TCP 1521 port traffic between these IP addresses or ranges of IP addresses.  As I recall, this issue is discussed in the Oracle Install Guide for windows as well.

    I had some notes on installing Oracle on Windows, but at the moment, cannot find the TEXT file.

     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 31, 2011 10:45 PM
  • User470161102 posted

    I have the similar problems deploying on test server 

    my configurations reads are follows:

    • Windows 2008 x64
    • IIS 7
    • Visual Studio 2008 SP1
    • ODAC10203x64 (Oracle ODP)
    Finally i followed the steps in Solution #1 from the below link. This worked successfully.
    Monday, July 25, 2011 4:46 AM
  • User410106628 posted

    I've just had to solve this issue.  Mine turned out to be that the app pool was set to "Enable 32 bit applications", meaning it was running as a 32 bit app and couldn't load the installed 64 bit dll.

    Tuesday, December 20, 2011 6:02 AM