如何从Visual Studio中引用GAC中的dll? [英] How can I reference a dll in the GAC from Visual Studio?

查看:169
本文介绍了如何从Visual Studio中引用GAC中的dll?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此程序集在GAC中:Microsoft.SqlServer.Management.RegisteredServers.dll

This assembly is in the GAC: Microsoft.SqlServer.Management.RegisteredServers.dll

如何在Visual Studio中添加对此程序集的引用?

How can I add a reference to this assembly in Visual Studio?

我可以在c:\ windows \ assembly \

I can view the file in c:\windows\assembly\

推荐答案

正如其他人所说,大多数情况下,您不会这样做,因为它不会将程序集复制到您的项目中,并且不会与您的项目一起部署.但是,如果您像我一样,并尝试添加所有目标计算机在其GAC中具有的引用,但它不是.NET Framework程序集:

As the others said, most of the time you won't want to do that because it doesn't copy the assembly to your project and it won't deploy with your project. However, if you're like me, and trying to add a reference that all target machines have in their GAC but it's not a .NET Framework assembly:

  1. 打开Windows运行"对话框(Windows键+ r)
  2. 键入C:\ Windows \ assembly \ gac_msil.这是某种怪异的hack,可让您浏览GAC.您只能通过运行对话框来找到它.希望我传播此信息最终不会导致Microsoft对其进行补丁和阻止. (太偏执?:P)
  3. 找到您的程序集并从地址栏中复制其路径.
  4. 在Visual Studio中打开添加引用"对话框,然后选择浏览"选项卡.
  5. 粘贴到GAC程序集的路径.

我不知道是否有更简单的方法,但是我没有找到它.我还经常使用步骤1-3将.pdb文件及其GAC程序集放置在一起,以确保它们在以后需要使用Remote Debugger时不会丢失.

I don't know if there's an easier way, but I haven't found it. I also frequently use step 1-3 to place .pdb files with their GAC assemblies to make sure they're not lost when I later need to use Remote Debugger.

这篇关于如何从Visual Studio中引用GAC中的dll?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆