Try putting the tnsnames.ora under the ORACLE_HOME/network/admin directory for unmanaged ODP.NET.
One side note: The error you are getting is a managed code error. Make sure you are using unmanaged ODP.NET if that is what you are intending to use.
Thanks for your support.
I actually want to use managed code. My impression is that, I don't need to install Managed code as long as I bundle managed dlls wth my application for deployment. Is this correct understanding? I actuall did this in my window 2003 server without install managed code and successfully connected to oracle server. Also this is what it does from the video presentation from you.
The issue is from widow XP, one of my dev machine. I need to distribute my web service to this window XP for testing and it got issue mentioned above. I have managed dll Oracle.managedDataAccess.dll and tnsnames.ora in this deployment package. same as I did in window 2003 server. But this could not connect to oracle server. Please advise for what can do to resolve it. I have no issue to use unmanaged code.
I already have this tnsnames.ora in unmanaged code folder ORACLE_HOME/network/admin directory for unmanaged ODP.NET. I still got the same error.
One caveat: Managed ODP.NET is not supported on Windows XP (nor 2003). Now, there isn't anything technically I'm aware of that wouldn't allow managed ODP.NET to run fine on XP. It's just that Microsoft will desupport XP in the near future and we chose to focus our bug fixing and testing resources on newer Windows platforms.
I got mixed up when you said Oracle.DataAccess since that's an unamanged ODP.NET DLL.
In any case, all you need to do is put tnsnames.ora in you current working application directory and it should run fine. That would be your bin\debug directory in a VS project. If it's there, next thing to check is whether your tnsnames.ora file has valid entries. It can be somewhat difficult to eyeball whether you've got a valid entry unless you've worked with Oracle connect descriptors a lot in the past. The easiest way to check is just to copy the entire connect descriptor and insert it as the Data Source attribute in your connection string. For example:
"User Id=hr; Password=xxx; Data Source = (DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = orcl)));"
Yes. Put connection string into web.config works. But could not make it work in window XP if use tnsnames.ora. I have put this file on any folder I can, such as VS project root, bin, debug, etc. The tns entry is correct becsue if I switch to unmanaged code, the tns entry can be recognized. No clue so far why the tns entry in tnsnames.ora file in window XP could not work.
Thanks Alex for your help. If I found the cuase of this issue, will update this post.