System.DllNotFoundException: Unable to load DLL 'oci' when published to IIS

2.4k Views Asked by At

I have a .net core application and I have to use System.Data.OracleClient.dll to connect with oracle db.

Everything works when I run this in VS2017 but when I publish and try to run the part that connects to the database I get an error:

System.DllNotFoundException: Unable to load DLL 'oci': The specified module could not be found. (Exception from HRESULT: 0x8007007E) at System.Data.OracleClient.Oci.OciCalls.OciNativeCalls.OCIEnvCreate(IntPtr& envhpp, OciEnvironmentMode mode, IntPtr ctxp, IntPtr malocfp, IntPtr ralocfp, IntPtr mfreep, Int32 xtramem_sz, IntPtr usrmempp)

Am I missing some kind of IIS module? I have x64 bit oracle in same PC.

2

There are 2 best solutions below

0
On

For me finally helped following steps:

  1. Got x86 Oracle Instant client from (http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html)
  2. Added instant client folder to environment path to the first position so that it will precede all other oracle paths.
  3. Restarted machine.
0
On

Could be you are missing the native code that the OciCalls class calls into, maybe some native dll or similar, or it's not finding it in the places it's looking, in any case you can debug this using the Assembly Binding Log Viewer to see where it's probing and what is missing.