Ok, this one goes in the infuriating category, because I quite literally spent days on it. Everybody who's tried to interface with Oracle should know the ORA-12154 error, TNS:could not resolve the connect identifier specified. Basically it means failed to connect to the database because the driver can't figure out what you want to connect to. Normally that's a problem with TNSNAMES.ORA or something similar. (A bad username/password would be a different error.)
Well, I started getting this in a Solution I'd been working in. Couldn't understand why. I was simply creating a new console application that linked into an object framework of my own creation that I was using in plenty of other places. I kept assuming it had something to do with my connection string, since I can never remember whether it's "User Id" or "UID" and all that nonsense.
Where it gets weird is that I'd create a new solution, create a test project...and it worked fine. So I know it's not my machine's ability to connect to the database. That is, not a TNSNAMES.ORA problem or anything like that.
So then I'd take my working project, link it into my solution, and it continues to work. Ok, cool. Create a new console application in my solution, and basically mirror everything that's in the working project, including dragging and dropping the App.config file (which contains the connection string) from good project to new project.
And it fails.
This went on for days. I tried every combination I could imagine. I checked the versions on all my DLLs. I diff'd every source file in the two directories. They were literally the exact same. Just a single line invoking a common library they both shared, for pete's sake. So it's not even like the error is in the common code, because it works for one but not the other.
At last, just now, I found it. Ready for the clear and obvious solution that makes all the sense in the world now that you see it?
There was a parenthesis in the directory name where my solution was stored. Apparently at some point when I wasn't paying attention I'd nested a reference to Foo and VS had created a directory called c:\Foo (2) where it was putting my solution.
I close the solution, rename the directory c:\Bar, and reopen the solution. Rebuild it (you have to rebuild it when you do that), and everything works fine. Rename it again and put the parenthesis back, and back comes the ORA-12154 error.
So, there you go. The problem was not in anything I wrote, it was in where it lived on the disk. Naturally when I created a project outside the solution and then linked it back in, it did not live in the same directory (even though it appeared to now be part of the solution). And when I created a new project, supposedly right next to the working one, I was really creating it inside of the bad directory. Maybe I'm the only person in the history of Visual Studio to have a parenthesis in a directory name, but I didn't even put it there, the software did it automatically and I never really paid it much attention. But when you have a parenthesis in the directory where your solution is stored, it will manifest itself as a "TNS:cannot resolve connect identifier" error.
Have I mentioned how much I hate this technology recently?