Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
574 views
in Technique[技术] by (71.8m points)

c# - OracleConnection is throwing empty exception

I'm trying to connect to my Oracle Database from my new PC. I've just installed Visual Studio and the ODAC. But when I try to do a simple connect Im getting an exception with an empty message, empty source, empty number, just with the error code which is -2147467259.

OracleConnection Prueba;
Prueba = new OracleConnection("Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXX.XXX.XXX.XXX)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XXXX)));User Id=XXX;Password=XXX;Pooling=true;Max Pool Size=10;Min Pool Size=1");
Prueba.Open();

Exception Details
This is the Exception.ToString() code:

"Oracle.DataAccess.Client.OracleException at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at OracleConnectionS.Program.Main(String[] args) in C:UsersSimetriDocumentsVisual Studio 2010ProjectsOracleConnectionOracleConnectionProgram.cs:line 19"

Any idea about why could this be happening?

UPDATE

If I run visual studio as Administrator I dont get the exception and I can connect to the database just fine.

I tried giving FULL CONTROL permission to the Oracle Directory C:Oracle. But if I run Visual Studio in a normal way (not as administrator) I keep getting the exception.

Background Info
- I'm using Windows 7 64 bit
- Visual Studio 2010
- I can connect just find with SQL*PLUS

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

So after installing all sort of versions of ODAC and searching to every single post related to this.

At the end Clean Install of the 32bit version was the solution.

  • First you need to unistall all your other oracle client you have ever installed.
  • After that, look for any ODAC version you want (latest if posible) but be sure to download the 32 bit version.

WHY?

Well is something related to the version in which Visual Studio is developed in. If you are developing a console application you will have not problem with the client version, but if you are using a web project then you definitely need the 32 bit version.

  • Finally be sure that all of your projects in visual studio the target platform is "32 bit"
  • and reference the new Oracle.DataAccess.dll that you have just installed

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...