11 Replies Latest reply: Nov 7, 2012 11:59 AM by 963110 RSS

    Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc

      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 scenario on development machine fitted on:
      1. 32-bit ODP.net installed on 32-bit O/S
      2. .NET application compiled with "Any CPU" set for "Plataform target"
      3. The application is then deployed to the 64-bit host with 64-bit ODP.NET installed. (I'm abble to to tnsping, connect to sqlplus)
      4. The application server is x64bits and the database server is 32bits. (I'm able to run and compile the APPLICATION using visual studio in a development machine)
      5. I tried the following solutions:
      a) to enable 32-bit applications in my default AppPool (I get the error with CrystalDecision - SapCrystalReports in the deployment)
      b) to install 32-bit ODP.net on the deployment machine with 64-bit os, but i got a runtime error
      c) to set all the projects in my solutions .NET application compiled from "Any CPU" to "x64" set for "Plataform target",but the error persist

      Please assist me on this issue.
        • 1. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
          I am having the same issue.
          I will let you know once I find something.
          btw you can go on path 5.a -- just need to resolve the crystal reports issue.

          In the mean time also read this article which I found useful to understand the configurations in Visual Studio
          • 2. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
            Check to make sure you don't have Copy Local = True on your Oracle.DataAccess reference in your project properties. If you do, set it to false and delete the Oracle.DataAccess.dll that got copied into the \bin directory on the server.

            If that's turned on (and IIRC by default it is in some cases) you'll get an errant 32 bit Oracle DLL on your 64 bit machine.
            • 3. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
              In process to resolve this issue,

              1) found that the appication dll has Oracle datasccess dll reference information with a specific path
              This reference information is contained in the Application assembly (dll ).
              If the same path is not found on the production deployment machine the deployment fails to load the oracle dll.

              2) Also If the application is compiled for 32 bit deployment but the reference is to 64 bit Oracle dll then again the app pool fails to load it
              • 4. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                try Add tag to your application web.config
                <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342" culture="neutral" />
                <bindingRedirect oldVersion="" newVersion="" />

                add the above tag to web.config of deployment machine and set the newVersion="" corresponding to the Oracle client deployed on that machine. If there are two clients installed on the machine then take the one which is working. Only one client installation works at a time.
                • 5. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                  What I did awhile back is made sure the following files were included in my main project and set to CopyAlways:


                  This is basically the core of Oracle Instant Client, and it seemed to have resolved my issue (though, granted, it ment for some rather large deployments).

                  Also, remember to go in your ApplicationFiles (in VS, this would be under Publish->Application Files) and toggle Oracle.DataAccess.dll to Include and required.

                  I hope this helps.
                  • 6. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                    It looks like you did what I did to correct this problem.
                    Something that I just found out, since we a basically creating our own Oracle client, Oracle (the organization) does like that, and legally we can't deploy our database tool.
                    I'm trying to found out exactly how to do it the correct way, but no luck yet.
                    Something you might want to look into.
                    • 7. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                      I'm not sure that that violates the EULA, though, as Oracle Instant Client is meant to be bundled with other applications.

                      However, what I've done more recently (as a FAT deploy solution doesn't work so well with EF anyway) is downloaded OracleInstantClient with XCOPY deployment and placed that somewhere on my server. Then, I check the machine.config for oracle.dataaccess. If this isn't found, then I execute install.bat odp.net4 [destination directory] true.

                      Of course, if you're developing for Win 7/Vista users, you'll run into issues with users not having administrative rights to modify machine.config. To get around this, I had to split install.bat into two .bat files, one that handles all the copying, and one (which is copied locally along with configure.bat) to handle configuration. Then, I can do the configuration part with (in c#) if (System.Environment.OSVersion.Version.Major>=6) [process object].StartInfo.Verb="runas";.

                      Hope this helps.

                      Edited by: 929933 on Nov 6, 2012 2:24 PM
                      • 8. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                        I'm developing this tool for use on any computer which could access the Oracle database (may or may not have our product running).
                        It could just be the product admin running on his own computer.
                        ~80% of the time, the product admin is a system admin, but not always, so we have to build this tool for worst case.

                        We have the product still running on XP machines, but we're coding for Win7 machines.

                        This is a troubleshooting tool to pull some values out of the client's database, bypassing anything that may be corrupted (tns.ora).
                        We need to make sure, for one, that our customers are actually running their db upgrade scripts for the maint releases.

                        Can you supply some sample code for what you are doing?
                        • 9. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                          Okay, so in install.bat, do a search for configure.bat and place an REM before any of the calls (effectively commenting them out).

                          Then I have two batch files I created: installhelper.bat and configurehelper.bat (of course, you could just pass the arguments directly into the process.startinfo, but I chose to manage this via old fashioned DOS.

                          in InstallHelper.Bat, I have:
                          @call Install.Bat ODP.Net4 C:\OracleInstantClient True
                          @copy .\configure.bat c:\OracleInstantClient\configure.bat
                          @copy .\configurehelper.bat c:\OracleInstantClient\configurehelper.bat

                          in ConfigureHelper.bat, I have:
                          @call C:\OracleInstantClient\configure.bat odp.net4 true

                          Then, in c#, my code is as follows:
                          private const string STR_FOLDER_NAME = @"C:\OracleInstantClient";
                          private const string STR_INSTALL_LOCATION = "[MY NETWORK PATH]";

                          private static bool CheckMachineConfig()
                          bool boolReturn = false;
                          string strPath = string.Format(@"C:\{0}\Microsoft.NET\Framework\v4.0.30319\Config\machine.config", System.Environment.SpecialFolder.Windows);
                          FileInfo fi = new FileInfo(strPath);
                          if (fi.Exists)
                          using (StreamReader sr = new StreamReader(strPath))
                          string str = sr.ReadToEnd();
                          boolReturn = str.Contains("oracle.dataaccess.client");
                          boolReturn = false;
                          fi = null;
                          return boolReturn;

                          public static bool InstallIC()
                          if (!CheckMachineConfig())
                          using (Process prc = new Process())
                          prc.StartInfo = new ProcessStartInfo(STR_INSTALL_LOCATION + "installHelper.bat");
                          prc.StartInfo.WorkingDirectory = STR_INSTALL_LOCATION;
                          using (Process prc2 = new Process())
                          prc2.StartInfo = new ProcessStartInfo(string.Format("{0}\\ConfigureHelper.bat", STR_FOLDER_NAME));
                          prc2.StartInfo.WorkingDirectory = STR_FOLDER_NAME + "\\";
                          if (System.Environment.OSVersion.Version.Major >= 6)
                          prc2.StartInfo.Verb = "runas";
                          return true;
                          else return false;
                          One other note: the default install.bat redirects CommandPrompt Echo's to an Install.Log file. For me, I felt it was more important that my end-users don't think the CommandPrompt is hanging, so I removed the redirect and had everything echo out to CommandPrompt. If you can make sense of the install.bat file, however (and I'm assuming any Windows programmer knows their way around DOS), then you can easily build your own process to copy all the files/folders somewhere, supply your own UI cues, and manage install.log directly from C# (then it'll just be a matter of running the configure.bat file with the correct arguments).

                          Hope this helps.

                          EDIT: I should also point out that, obviously, to use anything that invokes XCOPY, you'll need the network drive mapped. You can map it yourself in C# if this is an issue, or go the UI route and just copy the files you need using System.IO library directly in C#.

                          Edited by: 929933 on Nov 6, 2012 3:36 PM

                          Edited by: 929933 on Nov 7, 2012 1:21 PM
                          • 10. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                            Just moved over to the Oracle.ManagedDataAccess.dll (requires .NET 4) and it works great!
                            Happy Camper!
                            • 11. Re: Could not load file or assembly 'Oracle.DataAccess' or one of its dependenc
                              tks for the help, but I found a single dll that uses my same calls...
                              Oracle.ManagedDataAccess.dll (requires .NET 4)