views:

730

answers:

3

Duplicate of: Getting assemblies to show in the .NET tab of Add Reference

So, I'm using Visual C# 2008 Express Edition and I've just been on a bit of a detour as I found out that my assumption that the .NET tab of the 'Add Reference' dialog lists the contents of the GAC was incorrect.

This was a bit of a problem for me as the assembly that I wanted to reference from my project was only available in the GAC. (It was Microsoft.XNA.Framework v2.0 obtained from the XNA 2.0 redistributalbe and as far as I could see it installed only into the GAC).

I worked round the problem by setting the reference to Microsoft.XNA.Framework manually in the .csproj file and then getting a copy of the dll out of the cache. I was then able to create a directory for the DLL, add it to Visual Studio's list of assembly directories in the registry and then voila! I could see it in the .NET tab.

This all seems like a bit of a faff to me and I don't think that my initial assumption (that the .NET tab shows the contents of the GAC) was that unreasonable or would be that uncommon. Can someone who knows more than me tell me

  • why the contents of the GAC aren't shown? The documentation just says that they are not, but is there a good reason?
  • is there actually a way to get the entire contents of the GAC to be listed? A tick box I've missed somewhere?

Any info much appreciated.

+1  A: 

Please see: Getting assemblies to show in the .NET tab of Add Reference

Mitch Wheat
Thanks for the link but with all due respect I don't think that this is a duplicate of the 'Getting assemblies to show in the .NET tab of Add Reference'. As you can see from the text of my question, I'm already able to use the registry method to get an individual assembly or directory of assemblies to appear in the .NET tab but I was wondering is there was a way to get the entire GAC to appear in one go, and if anyone (probably Microsoft affiliated) has any insight as to why it doesn't appear there by default. The main thing I get from the link is that the GAC should be avoided. Regards Alan
abroun
+2  A: 

You're making the assumption that the .NET tab means GAC but it doesn't. It means installed assemblies, which may or may not be in the GAC. Some installations go under Program Files and those assemblies are then visible in the .NET tab.

When you add a reference to a project (ignore Web Site projects, as they're a bastard child anomaly and need to DIAF) the .NET runtime will locate that assembly using a cascading search that starts in the executable directory, checks the PATH environment variable and ends in the GAC. I don't have a link, but there is at least one good article on MSDN that specifically explains this.

The above may not seem to directly correlate here, but it does in the sense that when you're developing you can make a reference to an assembly somewhere on your development machine, but then when you distribute your application to another machine for production use, that assembly doesn't necessarily have to be in the same place as it was on your development machine. When you're developing you can have the assembly local, or in Program Files, but then on another machine if that assembly is in the GAC then your program should just work.

(Typically when you install an SDK the installer will be smart enough to create the registry entries needed to show the dll's in the .NET tab. Your XNA framework example may come down to you installing the runtime package instead of the SDK or something.)

Hope that helps.

sliderhouserules
A: 

Download and use the Muse VSReferences extensions. It will do all of this automatically for you

Muse VSExtensions