为什么我仅在 VS 2008 Web 应用程序/站点项目中收到 Oracle 连接错误?
在 Vista 64 位上使用 Visual Studio 2008,如果我创建一个如下所示的测试网站或 Web 应用程序...
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OracleConnection connection;
connection = new OracleConnection("User Id=user;Password=userpass;Data Source=dataSource;");
connection.Open();
}
}
...并运行它,我会收到以下错误。
ORA-12154: TNS:could not resolve the connect identifier specified
我知道有关父母的这个问题...... http://duanesbrain.blogspot。 com/2007/01/ora-12154-using-c-with-microsoft-visual.html
Visual Studio 2008 安装在 Program Files (x86) 中,但另一个开发人员具有相同的设置,并且对他来说工作正常。 项目本身不在名称带有括号的目录中。
我知道这不是我的 tnsnames.ora 或我的 sqlnet.ora 文件。 我的机器设置方式与所有在该项目上工作时间比我长得多的开发人员完全相同。
我也 100% 确定我使用的连接字符串是正确的。
如果我使用相同的代码创建一个控制台应用程序,它可以正常连接。 我可以 ping Oracle 服务器并使用该连接字符串信息直接通过命令提示符进行连接。
另一个奇怪的事情是,如果我使用 VS 2005(也安装在 Program Files (x86) 中)使用相同的代码创建一个 Web 应用程序或网站,它也可以正常工作。
它似乎仅限于仅使用 VS 2008 的 Web 应用程序和网站。
编辑:我应该补充一点,我的 oracle 文件夹目前拥有授予每个人的所有权限。
编辑: Oracle 版本是 10.2.0
编辑: 感谢您的见解,我永远无法让它工作,而其他开发人员和我决定构建一个会更快XP 虚拟机可以工作。 几个小时后,我就完成了设置,一切都运行良好。
Using Visual Studio 2008 on Vista 64 bit, if I create a test web site or web application that looks like this...
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
OracleConnection connection;
connection = new OracleConnection("User Id=user;Password=userpass;Data Source=dataSource;");
connection.Open();
}
}
...and run it, I get the following error.
ORA-12154: TNS:could not resolve the connect identifier specified
I'm aware of this issue regarding parens...
http://duanesbrain.blogspot.com/2007/01/ora-12154-using-c-with-microsoft-visual.html
Visual Studio 2008 is installed in Program Files (x86) but another dev has that same setup and it works fine for him. The project itself is not within a directory with a name that has parens.
I know it's not my tnsnames.ora or my sqlnet.ora files. I have my machine set up the exact same way as all the devs who've been working on this project for a lot longer than I.
I am also 100% certain the connection string I am using is correct.
If I create a console application with the same exact code, it connects fine. I can ping the oracle server and connect directly through command prompt using that connection string info also.
Another odd thing is that if I create a web application or web site with the same code using VS 2005 (also installed in Program Files (x86)) it works fine as well.
It seems to be restricted to web applications and sites only using VS 2008.
EDIT: I should add that my oracle folder has all permissions given to everyone currently.
EDIT: Oracle version is 10.2.0
EDIT: Thanks for the insights, I never could get it to work and the other devs and I decided it would be faster to build an XP vm to work on. In a few hours I had one set up and everything runs fine.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
几个小时后我遇到了同样的问题!
发现Oracle安装的版本没有更新。
我安装了 10.2.0.4 和 Viola(在 10.2.0.1 上它不起作用!)一些 Oracle Bug。
I got the same issue and after several HOURS!!!..
Found out that the version of the Oracle installation was not updated.
I installed 10.2.0.4 and Viola (On 10.2.0.1 it does not work!) Some Oracle Bug.
在调试和发布模式下都会发生这种情况吗? 您是使用 WebDev.WebServer.exe (casini) exe Web 服务器还是使用 IIS 运行该网站。 尝试切换到另一台。 这种情况是只在调试时发生还是在运行时发生?
也许该网站正在作为不同的用户/进程运行,并且该帐户没有为oralce配置路径?
Does this happen in both debug and release modes? Are you ruunning the website with the WebDev.WebServer.exe (casini) exe web server or with IIS. Try switching to the other one. Does this happen only when you debug or when you are running it as well?
Perhaps this website is running as a different user / process and this account does not have the paths configured for oralce?
我之前在使用oracle home时遇到过问题。 您能否检查并根据需要修改注册表以确保 ORACLE_HOME 设置正确。 注册表路径是 HKLM\SOFTWARE\ORACLE\
我有一个名为 KEY_OraOdac11h_home1 的键,ORACLE_HOME 的值是我安装 Oracle 客户端的文件路径 (C:\Oracle\product\11.1.0\client_1)
您也可以尝试添加系统环境变量 ORACLE_HOME,值为 C:\Oracle\product\11.1.0\client_1。
将文件路径更改为安装oracle客户端的位置。
I had problems with oracle home before. Can you check and if required modify he registry to ensure that ORACLE_HOME is setup correctly. the registry path is HKLM\SOFTWARE\ORACLE\
I have a key named KEY_OraOdac11h_home1 and the value for ORACLE_HOME is the file path to where I installed the Oracle client (C:\Oracle\product\11.1.0\client_1)
You can also try adding the system environment variable ORACLE_HOME with value C:\Oracle\product\11.1.0\client_1.
Change the file path to where you have installed oracle client.
您看到的错误消息表明以下之一存在问题:tnsnames.ora 文件、sqlnet.ora 文件或数据源值。 您应该检查这些文件的其他开发人员的版本。
您是否尝试过使用 EZCONNECT 方法来验证连接? (请参阅 www.connectionstrings.com/oracle)您可能需要修改 sqlnet.ora 文件以启用 EZCONNECT。
The error message you are seeing indicates a problem in one of: your tnsnames.ora file, your sqlnet.ora file, or your Data Source value. You should check the other developer's versions of these files.
Have you tried using the EZCONNECT method to verify connectivity? (see www.connectionstrings.com/oracle) You may need to modify your sqlnet.ora file to enable EZCONNECT.
是64位/32位的问题吗? 您可以尝试将项目设置为构建 32 位,然后强制 IIS 进入 32 位模式。
如何更改 IIS:http://support.microsoft.com/kb/894435
Is it a 64bit/32bit problem? You could try setting the project to build 32bit, then force IIS into 32bit mode.
How to change IIS: http://support.microsoft.com/kb/894435
当我尝试通过 .NET 连接到 Oracle 时,我遇到了混合结果和奇怪的问题,通常这是一个奇怪的环境设置问题。
尝试此连接字符串(不使用 tns 文件,但使用其中的相同详细信息)
数据源=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=HOST IP)(PORT=1521))) (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SERVICENAME)));用户 ID=USERID;密码=PASSWORD;
这将帮助您开始查看是否是您连接到 Oracle 时出现的问题,或者您的 TNS 文件是否未正确解析。
SOFTWARE\ORACLE\ 中应该有一些内容,例如 HOME、ALL_HOMES、HOME0 等,因为这是驱动程序识别您的 Oracle 主目录并注册 TNS 文件的方式。
我还会查看您运行 VS 的开发盒上的防火墙,并检查您的 dll 引用,以确保您使用相同的 Oracle Dlls - 您使用的是 MS oracle dll 还是 Oracle 的 dll?
I've experienced mixed results and odd issues when attempting to connect to Oracle through .NET and usually it's an odd environment setup issue.
Try this connection string (does not use the tns file but uses the same details inside of it)
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=HOST IP)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=SERVICENAME)));User Id=USERID;Password=PASSWORD;
This will get you started to see if it's an issue with you connecting to Oracle or if your TNS file is not resolving appropriately.
You should have something in SOFTWARE\ORACLE\ such as HOME, ALL_HOMES, HOME0, etc because this is how the drivers identify your oracle home and register the TNS files.
I would also look at your firewall on the developement box you're running VS on and check your dll references to make sure you are using the same Oracle Dlls - also are you using the MS oracle dlls or the ones from Oracle?