如何从GAC中提取组件?

时间:2021-11-04 02:46:21

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

我必须处理一个包,它将程序集直接安装到GAC中(例如,在%windows%/assembly中的某个位置)。

How do I exorcise the actual assembly (the DLL) from the GAC into the normal file system?

如何将实际的程序集(DLL)从GAC导出到普通文件系统?

Thanks.

谢谢。

15 个解决方案

#1


142  

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

我使用了本文的建议从GAC获得一个程序集。

Get DLL Out of The GAC

从GAC中取出DLL

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.

在GAC中部署的DLL(通常位于c:\windows\程序集)不能作为一个普通的DLL文件查看或使用。它们不能直接从VS项目中引用。开发人员通常保存原始DLL文件的副本,并在开发(设计)时在项目中引用该文件,在项目运行时使用GAC的程序集。

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

在执行(运行时)如果发现组装和部署在签署广汽CLR自动接组装广汽DLL的引用而不是在设计时在与开发人员删除原来的DLL或没有出于某种原因,有一个办法从广汽的DLL文件。按照以下步骤从GAC复制DLL

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

    运行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.
    • shfusion。dll是一个资源管理器扩展dll,它提供了GAC文件夹的独特外观。注销此文件将删除程序集缓存查看器,然后GAC文件夹将作为资源管理器中的任何普通文件夹可见。
  2. Open “%windir%\assembly\GAC_MSIL”.

    打开“%列出% \会议\ GAC_MSIL”。

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

    浏览到你的DLL文件夹到深处找到你的DLL。

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

    将DLL拷贝到硬盘上的某个地方,然后在项目中引用它

  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.

    运行“regsvr32 %列出% \ Microsoft.NET \ Framework \ <。净版目录> \ shfusion。“dll”重新注册shfusion。动态链接库文件并重新获得GAC的原始清晰视图。

#2


105  

The method described here is very easy:

这里描述的方法非常简单:

http://andreasglaser.net/post/2008/08/05/Extract-assembly-from-Global-Assembly-Cache-(GAC)-with-network-drive-mapping.aspx

-with-network-drive-mapping.aspx http://andreasglaser.net/post/2008/08/05/Extract-assembly-from-Global-Assembly-Cache-(GAC)

Summary from Article:

摘要从文章:

  • Map a Network Drive (Explorer -> Tools)
    • Map to \servername\folder (\\YourServer\C$\Windows\Assembly)
    • 地图\ servername \文件夹(\ \ YourServer \ \ Windows \组装加元)
  • 将网络驱动器(Explorer -> Tools)映射到\servername\文件夹(\\ \您的服务器\C$\Windows\Assembly)
  • No need for sharing if you are the Administrator
  • 如果您是管理员,则不需要共享
  • Browse to the drive and extract your assembly
  • 浏览到驱动器并提取程序集

#3


74  

Open the Command Prompt and Type :

打开命令提示符并键入:

cd  c:\windows\assembly\GAC_MSIL 

xcopy . C:\GacDump /s /y

This should give the dump of the entire GAC

这将导致整个GAC的转储

Enjoy!

享受吧!

#4


22  

Yes.

是的。

Add DisableCacheViewer Registry Key

添加DisableCacheViewer注册表键

Create a new dword key under HKLM\Software\Microsoft\Fusion\ with the name DisableCacheViewer and set it’s [DWORD] value to 1.

在HKLM\软件\Microsoft\Fusion\名称DisableCacheViewer下创建一个新的dword密钥,并将它的[dword]值设置为1。

Go back to Windows Explorer to the assembly folder and it will be the normal file system view.

回到Windows资源管理器到程序集文件夹,它将是普通的文件系统视图。

#5


15  

I think the easiest way is to do it through the command line like David mentions. The only trick is that the .dll isn't simply located at C:\Windows\Assembly. You have to navigate to C:\Windows\Assembly\GAC\[ASSEMBLY_NAME]\[VERSION_NUMBER]_[PUBLIC KEY]. You can then do a copy using:

我认为最简单的方法是像David提到的那样通过命令行完成。唯一的方法是,. dll并不是仅仅位于C:\Windows\Assembly.你需要导航到C:\Windows\Assembly\GAC\[ASSEMBLY_NAME]\[VERSION_NUMBER]_(公钥)。然后,你可以使用:

copy [ASSEMBLY_NAME].dll c:\ (or whatever location you want)

复制(ASSEMBLY_NAME)。dll c:\(或你想要的任何位置)

Hope that helps.

希望有帮助。

#6


12  

Easy way I have found is to open the command prompt and browse through the folder you mention until you find the DLL you want - you can then user the copy command to get it out. Windows Explorer has a "helpful" special view of this folder.

我发现的简单方法是打开命令提示符并浏览您提到的文件夹,直到找到您想要的DLL—然后您可以使用copy命令将其取出。Windows资源管理器有这个文件夹的“有用的”特殊视图。

#7


6  

Open RUN then type %windir%\assembly\GAC_MSIL, this will open your dlls in folders' view you can then navigate to your dll named folder and open it, you will find your dll file and copy it easily

打开运行然后键入%windir%\assembly\GAC_MSIL,这将打开文件夹视图中的dll,然后导航到您的dll命名的文件夹并打开它,您将找到您的dll文件并轻松复制它

#8


4  

I am the author of PowerShell GAC. With PowerShell GAC you can extract assemblies from the GAC without depending on GAC internals like changing folder structures.

我是PowerShell GAC的作者。使用PowerShell GAC,您可以从GAC中提取程序集,而无需依赖于GAC内部结构(如更改文件夹结构)。

Get-GacAssembly SomeCompany* | Get-GacAssemblyFile | Copy-Item -Dest C:\Temp\SomeCompany

#9


3  

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

这个MSDN博客文章描述了从GAC中提取DLL的三个不同的方法。到目前为止给出的方法的有用总结。

#10


2  

Use the file browser "Total Commander" instead.

使用文件浏览器“Total Commander”代替。

  1. Enable the "show hidden/system files" setting in Total Commander
  2. 在总指挥中启用“显示隐藏/系统文件”设置
  3. Browse to "c:\windows\assembly"
  4. 浏览到c:\ windows \大会”
  5. copy
  6. 复制

#11


2  

From a Powershell script, you can try this. I only had a single version of the assembly in the GAC so this worked just fine.

从Powershell脚本中,您可以尝试这样做。我只在GAC上有一个单一版本的程序集,所以这很好。

cd "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\"
Get-ChildItem assemblypath -Recurse -Include *.dll |  Copy-Item -Destination "c:\folder to copy to"

where the assembly path can use wildcards.

程序集路径可以使用通配符。

#12


2  

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:

我想我找到了一种方法,可以查看GAC内部,而无需修改注册表或使用命令行、powershell或任何其他程序:

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)

打开这个快捷方式将您带到GAC内部的系统文件夹(每个人都应该有这个文件夹),并且有一个很好的副作用,可以让您切换到更高的目录,然后浏览到您想要的任何其他文件夹(并查看dll文件,等等)

I tested this on windows 7 and windows server 2012.

我在windows 7和windows server 2012上进行了测试。

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

注意:它不会让您在创建快捷方式时使用该目标,但它会让您编辑它。

Enjoy!

享受吧!

#13


1  

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

只是导航到C:\Windows找到(组装)文件夹右键单击并选择add存档

wait a little

再等一段

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

您有一个包含GAC中所有程序集的归档文件

#14


0  

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

另一个方向——只需打开MSI文件,以这种方式获取好东西。使您免于最终的卸载…

#15


0  

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.

从命令行复制是不必要的。我从开始窗口搜索中输入了DLL的名称。我选择了更多的结果。GAC中的那个在搜索窗口中被返回。我右键点击它,然后说打开文件位置。它在普通的Windows资源管理器中打开。我复制文件。我关上了窗户。完成了。

#1


142  

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

我使用了本文的建议从GAC获得一个程序集。

Get DLL Out of The GAC

从GAC中取出DLL

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.

在GAC中部署的DLL(通常位于c:\windows\程序集)不能作为一个普通的DLL文件查看或使用。它们不能直接从VS项目中引用。开发人员通常保存原始DLL文件的副本,并在开发(设计)时在项目中引用该文件,在项目运行时使用GAC的程序集。

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

在执行(运行时)如果发现组装和部署在签署广汽CLR自动接组装广汽DLL的引用而不是在设计时在与开发人员删除原来的DLL或没有出于某种原因,有一个办法从广汽的DLL文件。按照以下步骤从GAC复制DLL

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

    运行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.
    • shfusion。dll是一个资源管理器扩展dll,它提供了GAC文件夹的独特外观。注销此文件将删除程序集缓存查看器,然后GAC文件夹将作为资源管理器中的任何普通文件夹可见。
  2. Open “%windir%\assembly\GAC_MSIL”.

    打开“%列出% \会议\ GAC_MSIL”。

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

    浏览到你的DLL文件夹到深处找到你的DLL。

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

    将DLL拷贝到硬盘上的某个地方,然后在项目中引用它

  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.

    运行“regsvr32 %列出% \ Microsoft.NET \ Framework \ <。净版目录> \ shfusion。“dll”重新注册shfusion。动态链接库文件并重新获得GAC的原始清晰视图。

#2


105  

The method described here is very easy:

这里描述的方法非常简单:

http://andreasglaser.net/post/2008/08/05/Extract-assembly-from-Global-Assembly-Cache-(GAC)-with-network-drive-mapping.aspx

-with-network-drive-mapping.aspx http://andreasglaser.net/post/2008/08/05/Extract-assembly-from-Global-Assembly-Cache-(GAC)

Summary from Article:

摘要从文章:

  • Map a Network Drive (Explorer -> Tools)
    • Map to \servername\folder (\\YourServer\C$\Windows\Assembly)
    • 地图\ servername \文件夹(\ \ YourServer \ \ Windows \组装加元)
  • 将网络驱动器(Explorer -> Tools)映射到\servername\文件夹(\\ \您的服务器\C$\Windows\Assembly)
  • No need for sharing if you are the Administrator
  • 如果您是管理员,则不需要共享
  • Browse to the drive and extract your assembly
  • 浏览到驱动器并提取程序集

#3


74  

Open the Command Prompt and Type :

打开命令提示符并键入:

cd  c:\windows\assembly\GAC_MSIL 

xcopy . C:\GacDump /s /y

This should give the dump of the entire GAC

这将导致整个GAC的转储

Enjoy!

享受吧!

#4


22  

Yes.

是的。

Add DisableCacheViewer Registry Key

添加DisableCacheViewer注册表键

Create a new dword key under HKLM\Software\Microsoft\Fusion\ with the name DisableCacheViewer and set it’s [DWORD] value to 1.

在HKLM\软件\Microsoft\Fusion\名称DisableCacheViewer下创建一个新的dword密钥,并将它的[dword]值设置为1。

Go back to Windows Explorer to the assembly folder and it will be the normal file system view.

回到Windows资源管理器到程序集文件夹,它将是普通的文件系统视图。

#5


15  

I think the easiest way is to do it through the command line like David mentions. The only trick is that the .dll isn't simply located at C:\Windows\Assembly. You have to navigate to C:\Windows\Assembly\GAC\[ASSEMBLY_NAME]\[VERSION_NUMBER]_[PUBLIC KEY]. You can then do a copy using:

我认为最简单的方法是像David提到的那样通过命令行完成。唯一的方法是,. dll并不是仅仅位于C:\Windows\Assembly.你需要导航到C:\Windows\Assembly\GAC\[ASSEMBLY_NAME]\[VERSION_NUMBER]_(公钥)。然后,你可以使用:

copy [ASSEMBLY_NAME].dll c:\ (or whatever location you want)

复制(ASSEMBLY_NAME)。dll c:\(或你想要的任何位置)

Hope that helps.

希望有帮助。

#6


12  

Easy way I have found is to open the command prompt and browse through the folder you mention until you find the DLL you want - you can then user the copy command to get it out. Windows Explorer has a "helpful" special view of this folder.

我发现的简单方法是打开命令提示符并浏览您提到的文件夹,直到找到您想要的DLL—然后您可以使用copy命令将其取出。Windows资源管理器有这个文件夹的“有用的”特殊视图。

#7


6  

Open RUN then type %windir%\assembly\GAC_MSIL, this will open your dlls in folders' view you can then navigate to your dll named folder and open it, you will find your dll file and copy it easily

打开运行然后键入%windir%\assembly\GAC_MSIL,这将打开文件夹视图中的dll,然后导航到您的dll命名的文件夹并打开它,您将找到您的dll文件并轻松复制它

#8


4  

I am the author of PowerShell GAC. With PowerShell GAC you can extract assemblies from the GAC without depending on GAC internals like changing folder structures.

我是PowerShell GAC的作者。使用PowerShell GAC,您可以从GAC中提取程序集,而无需依赖于GAC内部结构(如更改文件夹结构)。

Get-GacAssembly SomeCompany* | Get-GacAssemblyFile | Copy-Item -Dest C:\Temp\SomeCompany

#9


3  

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

这个MSDN博客文章描述了从GAC中提取DLL的三个不同的方法。到目前为止给出的方法的有用总结。

#10


2  

Use the file browser "Total Commander" instead.

使用文件浏览器“Total Commander”代替。

  1. Enable the "show hidden/system files" setting in Total Commander
  2. 在总指挥中启用“显示隐藏/系统文件”设置
  3. Browse to "c:\windows\assembly"
  4. 浏览到c:\ windows \大会”
  5. copy
  6. 复制

#11


2  

From a Powershell script, you can try this. I only had a single version of the assembly in the GAC so this worked just fine.

从Powershell脚本中,您可以尝试这样做。我只在GAC上有一个单一版本的程序集,所以这很好。

cd "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\"
Get-ChildItem assemblypath -Recurse -Include *.dll |  Copy-Item -Destination "c:\folder to copy to"

where the assembly path can use wildcards.

程序集路径可以使用通配符。

#12


2  

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:

我想我找到了一种方法,可以查看GAC内部,而无需修改注册表或使用命令行、powershell或任何其他程序:

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)

打开这个快捷方式将您带到GAC内部的系统文件夹(每个人都应该有这个文件夹),并且有一个很好的副作用,可以让您切换到更高的目录,然后浏览到您想要的任何其他文件夹(并查看dll文件,等等)

I tested this on windows 7 and windows server 2012.

我在windows 7和windows server 2012上进行了测试。

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

注意:它不会让您在创建快捷方式时使用该目标,但它会让您编辑它。

Enjoy!

享受吧!

#13


1  

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

只是导航到C:\Windows找到(组装)文件夹右键单击并选择add存档

wait a little

再等一段

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

您有一个包含GAC中所有程序集的归档文件

#14


0  

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

另一个方向——只需打开MSI文件,以这种方式获取好东西。使您免于最终的卸载…

#15


0  

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.

从命令行复制是不必要的。我从开始窗口搜索中输入了DLL的名称。我选择了更多的结果。GAC中的那个在搜索窗口中被返回。我右键点击它,然后说打开文件位置。它在普通的Windows资源管理器中打开。我复制文件。我关上了窗户。完成了。