2

I am new to using Microsoft development tools but have been using Visual Studio 2010, .NET 4 and C# for the past few weeks. I ran into a problem yesterday creating a new project the same way I have been doing it successfully from the start: right-click on the project in the Solution Explorer → Add Reference, which used to bring up this dialog:

Old Dialog Box http://img514.imageshack.us/img514/8978/oldaddreferencedialogue.jpg

After a couple of weeks of no new projects I went to create one yesterday and got a new Add Reference dialog. And trying to add the same dll I have been adding for weeks now resulted in the error seen here:

New Dialog http://img692.imageshack.us/img692/2074/newaddreferencedialogue.png

So, after a painful day trying to determine the cause, it looks to me like it has something to do with the new dialog choking on the # I had in my reference path. When I removed the # everything works as expected. Considering Microsoft has two .NET languages with # in the name, I am surprised that this issue keeps biting people (I have heard of this problem over the years, but I have never done much with Microsoft tools until recently, so of course I did not recall it.)

Questions from a Visual Studio newbie:

  1. Is it common knowledge to not use # in paths?

  2. How/why did I get this new Add Reference dialog when my colleagues, using the same VS version, still have the old dialog that handles # in paths just fine?

Josh Hemann
  • 940
  • 10
  • 12
  • Storing projects in N:\Development\C#\ directory in the past, I had many problems because of this, until I changed it to N:\Development\CSharp\. So yes, it is common knowledge to not use # in paths. – Arseni Mourzenko Jul 09 '10 at 21:54
  • John, thanks for adding the pro-power-tools tag and embedding the images. – Josh Hemann Jul 09 '10 at 22:00

2 Answers2

9

My opinion is that if you use weird characters in paths, you get what you deserve. :)

I know there are bugs about '#' character in paths in the core VS product, in addition to whatever may be in the Pro Power Tools extension. There is a surprising amount of code that goes to/from URIs and filenames, and '#' characters (and everything thereafter) get dropped when roundtripping via a System.Uri.

In general, I think it's safe to assume that when creating filenames/paths, there will be 10,000 tools of various quality trying to parse the filenames, and a (large) subset of those tools will fail on 'weird' characters. Just avoid weird characters whenever possible. You gotta choose your battles. In an ideal world, tools would be robust to these kinds of issues. In the real world, it's better to name a path "CSharp" rather than "C#" and move on with more important things in life.

Brian
  • 117,631
  • 17
  • 236
  • 300
  • (Wow, possibly my most immediately controversial answer ever!) – Brian Jul 09 '10 at 21:54
  • Why was this downvoted? You never know what OS your files might end up on, and not everything is supported by everyone. – Jouke van der Maas Jul 09 '10 at 21:56
  • Thanks for answering my first question; the URI issue is good to know. I think your final advice of "move on with more important things in life" is spot on. I just wanted to know if folks developing with Microsoft tools consider the # issue obvious. Again, it was not to me considering C# and F# projects would lend themselves to #s in filenames/paths. – Josh Hemann Jul 09 '10 at 21:57
  • I think it is not obvious unless (1) you've been bitten by it already or (2) you've written your own filename parsing tools and realize that every app that does it is likely to have bugs. – Brian Jul 09 '10 at 22:20
  • @MichaelMrozek - some visitors to SO are sensitive flowers who cannot distinguish banter from invective. – APC Jul 11 '10 at 07:10
  • +1 So true. Spent a day last week trying to install Oracle in a directory that contained a `(`, as in `Program Files (x86)`. If the Win64 designers had chosen a name like this answer suggests, countless compatibility issues would have been avoided. – Andomar Jul 11 '10 at 10:16
  • @APC: I found this question through the flagged list and am also puzzled why it's flagged; however, comments like your last really do make the situation worse. –  Jul 11 '10 at 22:53
3

The second dialog is the one from the VS2010 productivity power tools pack - I havent used it myself so dont know of any problems with it. Have you recently installed this?

Leom Burke
  • 8,143
  • 1
  • 35
  • 30
  • Ah, I think that is it. I did in fact install the Visual Studio 2010 Pro Power Tools a couple of weeks ago. I got it primarily for the Document Well functionality. On the list of other feature is "Searchable Add Reference Dialog" with a link to a good discussion around the new dialog versus the standard one. I'd vote the answer up if I had any reputation. Thanks! – Josh Hemann Jul 09 '10 at 21:43
  • @Josh - I have the Pro Power Tools pack installed and mimicked the same directory structure as you and got the same error, nice find! I'm sure they can fix this if it's reported. – John Rasch Jul 09 '10 at 21:50