Connection to Oracle works through a console appli

2019-05-11 10:09发布

I can't connect to an Oracle schema through a asmx web service instead of I can through a console application [x86].

The code:

var conn = new OracleConnection("Data Source=xe;User ID=mySchema;Password=myPass");

The exception:

ORA-12154: TNS:could not resolve the connect identifier specified

The environment: Windows 7 x64 - VS 2008.

Any idea?

kindly ask me for any extra information

Thanks in advance.

3条回答
放我归山
2楼-- · 2019-05-11 10:39

OCI, the Oracle client layer on which ODP (or the native Oracle client layer) is based has a bug that prevents any application located in a folder containing parentheses () from running properly

This bug is very visible since the apparition of the Program Files (x86) folder...

The host running your application (typically IIS) is probably located in the x86 folder, hence the issue. Your console app works fine because it's probably located in a folder that does not have the issue.

More info and a few solutions here.

查看更多
手持菜刀,她持情操
3楼-- · 2019-05-11 10:46

I got the exact same issue. I resolved by referencing Oracle.ManagedDataAccess.dll instead of Oracle.DataAccess.dll.

查看更多
Fickle 薄情
4楼-- · 2019-05-11 10:48

I'm not an Oracle guy in any way but I've run into similar situations in other databases. The problem we had was that the DSN was created as a User DSN and not a System DSN. I don't know how Oracle data sources are created but I would check this out.

查看更多
登录 后发表回答