0

I have a RESTful Api that inserts,deletes,updates and gets data from Oracle database. I have installed Oracle on my pc.
The app cracked continously, saying that Could not load file or assembly 'Oracle.DataAccess.I changed the Target platform of my project to x86 and it worked.
I am using a Chrome extension called Restlet Client to verify data that i am getting. If I am not using Oracle objects at all, it works and it gives me status ok.

 public IEnumerable<string> Get()
    {
        return new string[] { "1", "2" };

    }

enter image description here

If I am using Oracle object to connect to database like this

      public IEnumerable<string> Get()
        {
                DataSet ds;
                using (OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["Licenta"].ConnectionString))
                {
                  OracleDataAdapter adapter = new OracleDataAdapter(selectUsers,conn);
                  ds = new DataSet();
                   adapter.Fill(ds);

                }

            return new string[] { "1", "2" };
}

I am getting this error. enter image description here

Do you know why ?
I also tried with a dummy website and I have the same problem.

mihral
  • 323
  • 6
  • 19
  • If your web host is running in 64-bit mode, then it won't be able to load the x86 assembly. You need to have your web API compiled for x64, including a reference to a 64-bit version of Oracle.DataAccess.dll. – Jon May 05 '17 at 14:19
  • There are so many duplicates of this question on here http://stackoverflow.com/questions/15293975/could-not-load-file-or-assembly-oracle-dataaccess-error?rq=1 – Jon May 05 '17 at 14:20
  • If your program is x64 then you should use oracle libs for x64, and if they are not available, then change your program. The reason why you're not getting an error if not using any oracle objects at all is because the compiler will not try to load an assembly if there are no usages of it – ironstone13 May 05 '17 at 14:27
  • @Mangist I think those are old – andreim May 05 '17 at 14:27
  • I remember that there was an issue when the only driver available was x86, but that was in the past. You can look at [ODAC downloads](http://www.oracle.com/technetwork/topics/dotnet/downloads/index.html) or check ODP.NET on Nuget. – andreim May 05 '17 at 14:36
  • I changed in Advanced Settings of my pool in IIS the property Enable 32-bit Application to true and now I'm getting the error **404 not found**. In log files of IIS I have **404 0 2 0**. I search on google and I found that for running an Api I have to do this **""HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET\4.0.30319.0\EnableExtensionlessUrls" with a value of "0" then restart IIS to fix the issue."** Is it right? – mihral May 05 '17 at 15:14

0 Answers0