How to extract an assembly from the GAC?

后端 未结 15 1939
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 15:29

There is a package I have to deal with which installs assemblies straight into the GAC (e.g. somewhere deep in %windows%/assembly).

How do I exorcise the actual as

相关标签:
15条回答
  • 2020-11-29 15:44

    Think I figured out a way to look inside the GAC without modifying the registry or using the command line, powershell, or any other programs:

    Create a new shortcut (to anywhere). Then modify the shortcut to have the target be:

    %windir%\assembly\GAC_MSIL\System
    

    Opening this shortcut takes you to the System folder inside the GAC (which everyone should have) and has the wonderful side effect of letting you switch to a higher directory and then browsing into any other folder you want (and see the dll files, etc)

    I tested this on windows 7 and windows server 2012.

    Note: It will not let you use that target when creating the shortcut but it will let you edit it.

    Enjoy!

    0 讨论(0)
  • 2020-11-29 15:45

    This MSDN blog post describes three separate ways of extracting a DLL from the GAC. A useful summary of the methods so far given.

    0 讨论(0)
  • 2020-11-29 15:46

    just navigate to C:\Windows find the [assembly] folder right click and select add to archive

    wait a little

    vola you have an archive file containing all the assemblies in your GAC

    0 讨论(0)
  • 2020-11-29 15:47

    One other direction--just unpack the MSI file and get the goodies that way. Saves you from the eventual uninstall . . .

    0 讨论(0)
  • 2020-11-29 15:48

    Copying from a command line is unnecessary. I typed in the name of the DLL from the Start Window search. I chose See More Results. The one in the GAC was returned in the search window. I right clicked on it and said open file location. It opened in normal Windows Explorer. I copied the file. I closed the window. Done.

    0 讨论(0)
  • 2020-11-29 15:49

    I used the advice from this article to get an assembly from the GAC.

    Get DLL Out of The GAC

    DLLs once deployed in GAC (normally located at c:\windows\assembly) can’t be viewed or used as a normal DLL file. They can’t be directly referenced from VS project. Developers usually keep a copy of the original DLL file and refer to it in the project at development (design) time, which uses the assembly from GAC during run-time of the project.

    During execution (run-time) if the assembly is found to be signed and deployed in GAC the CLR automatically picks up the assembly from the GAC instead of the DLL referenced during design time in VS. In case the developer has deleted the original DLL or don't have it for some reason, there is a way to get the DLL file from GAC. Follow the following steps to copy DLL from GAC

    1. Run regsvr32 /u C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\shfusion.dll

      • shfusion.dll is an explorer extension DLL that gives a distinct look to the GAC folder. Unregistering this file will remove the assembly cache viewer and the GAC folder will be then visible as any normal folder in explorer.
    2. Open “%windir%\assembly\GAC_MSIL”.

    3. Browse to your DLL folder into the deep to find your DLL.

    4. Copy the DLL somewhere on your hard disk and refer it from there in your project

    5. Run "regsvr32 %windir%\Microsoft.NET\Framework\<.NET version directory> \shfusion.dll" to re-register the shfusion.dll file and regain the original distinct view of the GAC.

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