none
GAC Assemblies missing under Vista RRS feed

  • Question

  • Making a shared assembly. Made a strong name with the SN utility and signed the dll with the generated .snk file. Used gacutil to add it to the GAC. I can see it in there just fine, under \Windows\Assembly. Now go to a WinForm project and go to add a reference to it but it doesn't appear in the list of .NET components. Then I look and many many other assemblies in the GAC are not listed in there (and some that are listed and that are not even in the GAC). This is under Vista (32bit). What gives?

    Thanks,
    Rich Sienkiewicz
    High Fidelity Engineering
    Monday, September 8, 2008 7:38 PM

Answers

  • Reference assemblies play no role in your final program's execution.  They are only used during compilation to provide type info.  The compiler embeds the reference assembly's identity in the binary image (name, version, culture, public key token), nothing else.  When you run the image, the CLR loader's job is to find the dependent assemblies back.  It will now in fact consider assemblies in the GAC, if present.  That's how the .NET framework assemblies get loaded.

    If they are not in the GAC, you must provide a copy of the assembly in a location where the loader can find it.  The IDE's Copy Local property makes that easy.

    Hans Passant.
    • Proposed as answer by curt at amotif Wednesday, September 10, 2008 8:05 PM
    • Marked as answer by Zhi-Xin Ye Monday, September 15, 2008 7:00 AM
    Tuesday, September 9, 2008 5:29 PM
    Moderator

All replies

  • Reference assemblies cannot be stored in the GAC.  You must keep a copy of them in a well-known place.  It works the same way for the .NET framework assemblies, their well-known place is c:\windows\microsoft.net (and others).  Keep in mind that the reference assemblies are only needed on the machine on which you build the target.  Storing assemblies in the GAC on your dev machine is rarely useful, you should prefer the Copy Local option in the IDE so you'll have debugging symbols available.
    Hans Passant.
    Tuesday, September 9, 2008 2:12 AM
    Moderator
  • Yes, I understand to keep assemblies out of the GAC when debugging. But the question remains, when I put the assembly in the GAC, it cannot be added to a project because it's not listed in the Add Reference... dialog. Something about that assembly (and many many others) keep it from being in that list.
    Tuesday, September 9, 2008 12:25 PM
  • Again: the IDE will never look in the GAC for assemblies to display in the Add Reference dialog.  It searches folders for assemblies specified in the registry key HKLM\Software\Microsoft\.NETFramework\AssemblyFolders (and others).  The normal usage of that dialog for your own assemblies is the Browse tab.
    Hans Passant.
    Tuesday, September 9, 2008 12:46 PM
    Moderator
  • Then how/when does the runtime know to use the assembly in the GAC and not the one browsed to? How does the main app tell the runtime to use the GAC assembly, especially when it gets installed?
    Tuesday, September 9, 2008 3:49 PM
  • Reference assemblies play no role in your final program's execution.  They are only used during compilation to provide type info.  The compiler embeds the reference assembly's identity in the binary image (name, version, culture, public key token), nothing else.  When you run the image, the CLR loader's job is to find the dependent assemblies back.  It will now in fact consider assemblies in the GAC, if present.  That's how the .NET framework assemblies get loaded.

    If they are not in the GAC, you must provide a copy of the assembly in a location where the loader can find it.  The IDE's Copy Local property makes that easy.

    Hans Passant.
    • Proposed as answer by curt at amotif Wednesday, September 10, 2008 8:05 PM
    • Marked as answer by Zhi-Xin Ye Monday, September 15, 2008 7:00 AM
    Tuesday, September 9, 2008 5:29 PM
    Moderator
  • Thanks. After typing my last message I went and deleted the referenced dll, so the only copy of that shared assembly was in the GAC, and the main app ran fine, the runtime found the assembly that was in the GAC.
    Tuesday, September 9, 2008 5:36 PM