Introduction
We all know Add Reference is horribly broken in VS2008. We’ve all clicked it and had our hearts sink as we realised it was time to make a brew, grab lunch or take a weekend mini-break before even attempting to use Visual Studio again. Now VS2010 is in Release Candidate it’s obviously been fixed.. hasn’t it?!
Not All Change Is For the Better
The main issue with the VS2008 Add Reference dialog was that it took an age to load, mostly due to it enumerating all of the assemblies available to populate the .NET tab. If all you wanted to do was add a project or file reference you still had to wait for it to finish building the .NET tab. Not good. In an attempt to fix the problem Microsoft has made two major changes to the dialog for VS2010:
- The dialog now defaults to the Projects tab.
- The .NET tab is now multi-threaded i.e. it loads types in the background.
The first of the two fixes is an excellent idea. If you want to use the Projects, Browse or Recent tabs then you don’t even need to look at that snail-paced .NET tab.
The second of the two fixes is horrible. Truly horrible. I’d even go as far as to say that if you actually want to use the .NET tab to add a reference then it’s actually *more broken than Visual Studio 2008*. Yes, I did say that. And I’ll say it again:
“If you actually want to use the .NET tab to add a reference then it’s actually more broken than Visual Studio 2008.”
To illustrate the point, lets say we want to add MEF, which sits in System.ComponentModel.Composition to our application, we’d probably do something similar to the following:
- Click Add Reference.
- Marvel at how quickly Add Reference Loaded.
- Click the .NET tab.
- Watch the first few items start to load up.
- Type “Sys” to jump down to System in the list.
- Go to select System.ComponentModel.Compo..oh no.. it’s moved.
- Scroll down, go to select Sys.. nope.. it’s moved again.
- Scroll down a bit more, click on.. nope, gone again.
- Swear.
- Wait until the thing has fully finished loading and then select what we want.
So what we have there is the same delay as it would have taken with VS2008, but with the added “fun” of playing a game of “chase the reference down the listbox” in a vain attempt to save yourself a few seconds.
Could It Be Done Better?
Now I’m no User Experience expert, or an Interface Designer with a fancy job title, but couldn’t this be improved immeasurably with a simple filter box?
Perhaps I work in a strange way, but I never start searching for a reference using the mouse – I *always* type the first few letters to skip to roughly where I want to go. If we had a simple filter box at the top of the dialog then the “chase the reference” game would be massively reduced, and probably eliminated all together if you’d typed in enough of the namespace name:
Now we could get super fancy and support CamelCaseSearching like the QuickNav dialog in CodeRush, but I’d be quite happy with a basic filter.
Maybe I’m just picky.

I’m totally with you on this. A filter would be a simple solution to appease us at least partially.
I would probably also add some tricks to get this to load faster… maybe add a version identifier to the GAC, loading the namespace references in the background into a cache when you load up Visual Studio. Doing this in the background while you’re doing something other than waiting for the list is far less disruptive. When you go to load the Add References window, it’s merely a case of checking the version id of the GAC to see if it needs to be reloaded because 95% of the time it doesn’t as it doesn’t change during the course of our workflow. This way the list box can be built far quicker because the enumeration is already complete.
I would still default to the projects tab though, and I would still add your filter entry box to speed up searching. I think this combination of techniques would provide a markedly more usable interface.
As soon as the Add References window is opened, it should check the version to see if the GAC has been updated, if it has, it should start reloading the cache in the background so that if/when you click the .NET tab the list is already closer to completion than it would have been had it been built only upon clicking the .NET tab.
All suggestions for improvements to CR_ QuickAddReference (http://tinyurl.com/quickaddreference) are gratefully receeved here -> http://code.google.com/p/dxcorecommunityplugins/issues/entry
I think even if we made the add references dialog perfect (which, in itself, is suspect–considering it’s trying to solve multiple problems) it’s simply just exposing implementation details that we don’t really care about.
In terms of the GAC and project in the same solution Visual Studio has enough information to know exactly what assembly to reference. I shouldn’t need to tell it, before I use a namespace, which assembly to add a reference to.
Resharper effectively does this, I almost never need to use the add reference dialog with resharper. When I type using highnamespace.lownamespace or use a type that lives in an assembly that VS doesn’t have a reference to , R# figures out where that namespace/type is and suggests adding a particular assembly reference. I never need to know what assembly I need to add, in these cases.
Sure, assemblies that aren’t in the GAC, I need to manually add references to those; but then I’m just dealing with the Browse or the COM tabs. I could make the same argument for most COM binaries.
In terms of usability, Add Reference is basically flawed for types withing assemblies in the GAC or the current solution. I’d rather see better ways of dealing with those types instead of making the Add Reference dialog any different.
I’ve always thought the whole idea of adding a reference AND defining the namespace in my code was horribly wrong. Why should I have to do both? VS should be smart enough to go find (in the background) the assembly I need after I specify the namespace, then add it automaticly. If it can’t find it, then it can warn me that the namespace can’t be found. THEN I can bring up the Add References dialog.
@Peter @Craig – I don’t disagree, for GAC types it should be clever, but there are times when conflicts would occur so it’s not always as simple as it sounds, especially if you are doing it at type level rather than namespace level.
Yes, I was thinking the same thing when I saw it the first time… anyhow, wanted to share a tip until they get it fixed. E.g. when you type “Sys”, don’t use mouse to scroll, but rather go down with the keyboard arrow – that way it won’t move – the bottom of the screen will be always at the selected item.
I totally agree! This is very annoying..
Another slight annoyance comes when I add a new project to my solution and it’s using a different Target Framework by default then the rest of my solution. Instead of an error message saying something like “Target Framework 4.0 referenced project not compatible with Target Framework 3.5 project” it instead allows me to add the reference and gives me the oh-so-clever “The type or namespace name ‘Foo’ does not exist in the namespace ‘Goo’ (are you missing an assembly reference?)” I know, shame on me for not checking this, but the fix always eludes me for 2-3 minutes: right click on the new project->properties->change the target framework to what the other projects are using.
Do you ever find that your credibilty is ruined somewhat by your use of comic sans in screen mock-ups?