为什么“添加引用”中的 .NET 选项卡不显示? Visual Studio 中的对话框未列出 GAC 的内容?

发布于 2024-07-22 04:36:43 字数 783 浏览 1 评论 0原文

重复让程序集显示在“添加引用”的 .NET 选项卡中

因此,我使用的是 Visual C# 2008 Express Edition,而且我只是走了一点弯路,因为我发现我的假设是 .NET “添加引用”对话框的选项卡列出的 GAC 内容不正确。

这对我来说有点问题,因为我想从项目中引用的程序集仅在 GAC 中可用。 (它是从 XNA 2.0 redistributalbe 获得的 Microsoft.XNA.Framework v2.0,据我所知,它仅安装到 GAC 中)。

我通过在 .csproj 文件中手动设置对 Microsoft.XNA.Framework 的引用,然后从缓存中获取 dll 的副本来解决该问题。 然后,我可以为 DLL 创建一个目录,将其添加到注册表中 Visual Studio 的程序集目录列表中,然后瞧! 我可以在 .NET 选项卡中看到它。

这一切对我来说似乎有点奇怪,我不认为我最初的假设(.NET 选项卡显示 GAC 的内容)是不合理的或不常见的。 有比我了解更多的人可以告诉我

  • 为什么 GAC 的内容没有显示吗? 文档只是说它们不是,但是有充分的理由吗?
  • 实际上有没有办法让 GAC 的全部内容都列出来? 我在某处遗漏了一个勾选框?

任何信息都非常感谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伏妖词 2024-07-29 04:36:44

下载并使用 Muse VSReferences 扩展。 完成所有这一切

它会自动为您

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

s

土豪 2024-07-29 04:36:43

您假设 .NET 选项卡意味着 GAC,但事实并非如此。 它意味着已安装的程序集,可能位于或不位于 GAC 中。 某些安装位于“程序文件”下,然后这些程序集将在 .NET 选项卡中可见。

当您添加对项目的引用时(忽略网站项目,因为它们是混蛋子异常并且需要 DIAF),.NET 运行时将使用从可执行目录开始的级联搜索来定位该程序集,检查 PATH 环境变量并以 GAC 结束。 我没有链接,但 MSDN 上至少有一篇好文章专门解释了这一点。

上面的内容似乎与这里没有直接关联,但从某种意义上说,当您正在开发时,您可以在开发计算机上的某个位置引用程序集,但是当您将应用程序分发到另一台计算机以供生产使用时,该程序集不一定必须与您的开发计算机上的位置相同。 当您开发时,您可以将程序集放在本地或程序文件中,但然后在另一台计算机上,如果该程序集位于 GAC 中,那么您的程序应该可以正常工作。

(通常,当您安装 SDK 时,安装程​​序将足够智能地创建在 .NET 选项卡中显示 dll 所需的注册表项。您的 XNA 框架示例可能归结为您安装运行时包而不是 SDK 或其他东西。)

希望有帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文