How to reference a self made assembly that is installed in the GAC in visual studio?

ε祈祈猫儿з 提交于 2019-12-19 04:15:36

问题


I created a homemade assembly and I think I installed it correctly in the GAC using the .Net 2.0 configuration tool (mscorcfg.msu) However, when I want to reference it in visual studio, where do I find it?

( I know, I should not use the GAC anyway, but indulge me ;-))

EDIT: I did not ask the question clear enough: After installing the assembly to the GAC, it does not show up on the .NET tab of the Project-Add Reference menu.


回答1:


The add reference dialog actually looks at the registry, in particular:

  • [HKEY_LOCAL_MACHINE]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
  • [HKEY_CURRENT_USER]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders

To add your assembly, you must edit these registry keys. Or simply using the "Browse..." button (instead) may be more tempting.




回答2:


When you need to reference an assembly that has been deployed to the GAC, you will need to browse to the \bin\Debug directory of the original project via the Browse tab of the Add Reference dialog in Visual Studio.

The reason this works is that since you've installed the assembly into the GAC, it will have a strong name and therefore a .publickey value in the manifest.

When you reference an assembly whose manifest contains a .publickey value, Visual Studio assumes the strongly named assembly will most likely be deployed to the GAC, and therefore does not bother to copy the binary to your application folder.

Instead, it will use the version in the GAC.




回答3:


I've created a tool which is completely free, that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.

Hope this hekps,

Muse VSExtensions



来源:https://stackoverflow.com/questions/1024739/how-to-reference-a-self-made-assembly-that-is-installed-in-the-gac-in-visual-stu

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