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

后端 未结 3 981
礼貌的吻别
礼貌的吻别 2021-01-07 05:04

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 vi

相关标签:
3条回答
  • 2021-01-07 05:43

    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.

    0 讨论(0)
  • 2021-01-07 05:45

    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.

    0 讨论(0)
  • 2021-01-07 05:56

    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

    0 讨论(0)
提交回复
热议问题