Why does the .NET tab in the 'Add Reference' dialog in Visual Studio not list the contents of the GAC?

佐手、 提交于 2019-12-06 00:33:13

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.

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

s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!