System.DllNotFoundException: Unable to load DLL 'oci' when deployed to a Docker Linux container


I tried to use System.Data.OracleClient to connect with oracle db. My .net core application works well in vs2017 and IIS, but when I deploy to a Linux Container and run a part that gets a connection from the database I get this 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)

When I tried to run the run the part again, the error became:

System.NullReferenceException: Object reference not set to an instance of an object at System.Data.OracleClient.OracleConnectionPool.GetConnection () [0x00000] in :0 at System.Data.OracleClient.OracleConnection.Open () [0x00000] in :0

Any suggestions will be appreciated.

update: I removed System.Data.OracleClient and used Oracle.ManagedDataAccess.Core,the error gone. It's important to note that when use Oracle.ManagedDataAccess.Core version 2.18.3 ,you must set an environment variable called TZ to docker linxu container but in version 2.12.0-beta3 TZ is not necessary,for detail you can see here.

asked on Stack Overflow Dec 24, 2018 by sharedbest • edited Dec 29, 2018 by sharedbest

1 Answer


Even though the dependencies only show netstandard 2.0 I doubt the package works on .net core linux. It seems to have some dependencies on the .net famework. There's also an open issue here Unable to load DLL 'oci'.

Also the one on the ms docs is only available for .net framework. See here: System.Data.OracleClient

answered on Stack Overflow Dec 24, 2018 by zulqarnain • edited Dec 24, 2018 by zulqarnain

User contributions licensed under CC BY-SA 3.0