Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OracleException: Could not allocate the Oracle environment #11

Open
juniormayhe opened this issue Feb 28, 2018 · 1 comment
Open

OracleException: Could not allocate the Oracle environment #11

juniormayhe opened this issue Feb 28, 2018 · 1 comment

Comments

@juniormayhe
Copy link

I am having issues with this package. When Dapper tries to open connection (or I try to open it manually in debug mode), Visual Studio 2017 (under Windows 10) fires this exception:

OracleException: Could not allocate the Oracle environment.
System.Data.OracleClient.Oci.OciGlue.CreateConnection(OracleConnectionInfo conInfo)
System.Data.OracleClient.OracleConnectionPoolManager.CreateConnection(OracleConnectionInfo info)
System.Data.OracleClient.OracleConnectionPool.GetConnection()
System.Data.OracleClient.OracleConnection.Open()
Dapper.SqlMapper+<QueryImpl>d__136.MoveNext() in SqlMapper.cs
System.Collections.Generic.List.AddEnumerable(IEnumerable<T> enumerable)
System.Linq.Enumerable.ToList<TSource>(IEnumerable<TSource> source)

So it seems CreateConnection method is firing an error.

Connection string:

string connectionString = "Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.227)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = MYSERVICENAME)));User ID=myuser;Password=mypass;Unicode=True";
con = new OracleConnection(connectionString); //ok here 
con.Open(); //fails

Oracle client 12c is already installed here, other clients and software can connect to Oracle without any issues.

Not sure if this is related to environment variables. I have set all known oracle variables (TNS_ADMIN, ORACLE_HOME, ORACLE_BASE). I also had run Visual Studio as administrator but the exception keeps showing up.

The oracle platform seems to be really old and disheartening. 😞

@alissonsolitto
Copy link

alissonsolitto commented Mar 1, 2018

This tutorial is in Portuguese because I am Brazilian. In this tutorial I am not using Dapper, but in my actual application I have used this configuration along with Dapper and it worked very well.

Blog: https://solitto.com.br/csharp/oracle-data-provider-net-core/
GitHub: https://github.com/alissonsolitto/ProviderOracle

That's the part that can help you.

We must define the environment variables to reference the Oracle Client .DLL. In the example below the Oracle Instant Client folder is located in "C: \ instantclient_12_2".

LD_LIBRARY_PATH = "C:\instantclient_12_2"
OCI_HOME = "C:\instantclient_12_2"
OCI_LIB_DIR = "C:\instantclient_12_2"
PATH = "C:\instantclient_12_2"
NLS_LANG = "PORTUGUESE_BRAZIL.WE8MSWIN1252"

The NLS_LANG variable is important for correct encoding of text fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants