How can i get the location of the GAC using C#?

后端 未结 5 1458
攒了一身酷
攒了一身酷 2021-01-06 07:43

How can i get the location of the GAC directory using C#?

Exist an entry in the Windows Registry?

UPDATE

I need the

5条回答
  •  天涯浪人
    2021-01-06 08:18

    There are absolutely valid reasons to access the GAC manually like a folder. Of course, one should be aware of the risk manipulating things there. But read-only access is quite ok, I would say.

    Besides the mentioned %windir%\assembly, it might happen that Nir Sofer already did the job for you. He has written GACView.

    And hey, it even has a feature to disable the special view in Explorer: Options/Disable Assembly Viewer in Explorer. The folder will then show up as a normal folder. While this worked well on Windows XP, it doesn't on Windows 7 64 Bit, because it's setting it in the 32 Bit version of the Registry. To disable the assembly viewer on Windows 7 64 Bit, start Regedit (64 Bit), go to

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion
    

    and add a new DWORD called DisableCacheViewer with value 1.

    To be independent from the directory (which might change), you can enumerate assemblies via the Fusion Registry Key:

    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\GACChangeNotification\Default
    

    I guess this is how GACView works internally. But it still won't enumerate the .NET 4 assemblies in %windir%\Microsoft.NET\assembly.

    A tool which supports .NET 4 is GACBrowser, but it displays less information.

提交回复
热议问题