打开C:\ windows \会议\ gac_msil c#

时间:2022-06-17 02:45:59

How can I open C:\windows\assembly\gac_msil in a Windows Explorer window using C#?

如何使用c#在windows资源管理器窗口中打开C:\windows\ gac_msil ?

Explanation: When I deploy an assembly to the GAC in my development environment, I like deploying the .pdb symbol file to the same directory as the assembly located at C:\Windows\assembly\GAC_MSIL\AssemblyName\Version__PublicKeyToken\. That way if I want to attach the Visual Studio debugger, it automatically finds the symbol file.

解释:当我部署一个组装广汽的开发环境,我喜欢部署.pdb符号文件位于相同的目录大会C:\Windows\assembly\GAC_MSIL\ AssemblyName \ Version__PublicKeyToken \。这样,如果我想附加Visual Studio调试器,它会自动找到符号文件。

I've built a little utility that detects when I add one of my assemblies to the GAC and I want it to show a button that pops open the directory for me. I have the button and the path, but starting a process that launches explorer.exe with the path doesn't work. The only way I know of to open this directory in Windows is through the Run dialog.

我已经构建了一个小工具,当我将一个程序集添加到GAC时,它会检测到,我希望它显示一个为我打开目录的按钮。我有了按钮和路径,但启动了一个启动explorer的进程。用这条路走是行不通的。我知道在Windows中打开这个目录的唯一方法是通过Run对话框。

You can't get to it within explorer or using the command line command: explorer.exe "C:\Windows\assembly\GAC_MSIL...". Only if you type the path into the Run dialog. So how do I do what the Run dialog is doing?

您不能在资源管理器或使用命令行命令:explorer中到达它。exe“C:\ Windows \会议\ GAC_MSIL……”。只有当您在运行对话框中键入路径。那么我要怎么做运行对话框呢?

1 个解决方案

#1


1  

As Hans Passant at one time had answered, the old GAC is displayed by a shell extension which masks the directory structure. This is to make sure the assemblies in the GAC are managed properly. Opening the directory structure is intentionally not supported. In .NET 4, that is no longer the case so if you can upgrade, that's the way to go.

正如Hans Passant曾经回答的那样,旧的GAC是由一个外壳扩展所显示的,它掩住了目录结构。这是为了确保GAC中的程序集被正确地管理。不支持打开目录结构。在。net 4中,不再是这样了,如果你能升级,那就该走了。

To programmatically open the old GAC there are a few options but again, it is normally masked for a reason. Options:

为了以编程方式打开旧的GAC,有一些选项,但它通常是由于某种原因而被屏蔽的。选项:

  1. Remove the shell extension. You can unregister Shfusion.dll, open the directory, then re-register it. This, of course, could go wrong and leave you with Shfusion.dll permanently unregistered. This would allow other users to freely mess with the GAC directory structure and files which would cause it to become invalid and fall out of sync with the registry = bad.

    删除外壳扩展。你可以注销Shfusion。dll,打开目录,然后重新注册它。当然,这可能会出错,让你陷入混乱。dll永久注册。这将允许其他用户*地使用GAC目录结构和文件,这会导致它变得无效并与注册表不同步。

  2. Disable the shell extension. The HKLM Fusion registry key can have a DisableCacheViewer DWORD value. When set to 1, it will disable the view. The key can be set to 1, the window opened, then the key can be set back to 0. This approach has the same risks as option 1. Additionally, as a user (Damien) whose comment seems to have been deleted pointed out, other processes may also use this global key causing a race condition = bad.

    禁用外壳扩展。HKLM融合注册表键可以有一个DisableCacheViewer DWORD值。当设置为1时,它将禁用视图。可以将密钥设置为1,打开窗口,然后将密钥设置为0。这种方法与选项1具有相同的风险。另外,作为一个用户(Damien)的评论似乎已经被删除了,其他进程也可能使用这个全局键导致一个race条件= bad。

  3. Use a 3rd party application like Total Commander (thanks to Csaba Toth) or Far Manager to view the directory structure instead of Explorer. The downside here is, assuming they can even accept arguments to allow them to open to the GAC directory, it would require installing that software everywhere I want to run my app.

    使用像Total指挥官(感谢Csaba Toth)或Far Manager这样的第三方应用程序来查看目录结构而不是浏览器。这里的缺点是,假设他们甚至可以接受参数来允许他们打开GAC目录,那么在我想运行我的应用程序的任何地方都需要安装这个软件。

If you are considering using options 1 or 2, be aware that in most scenarios they are a bad idea and should be avoided unless you are messing around with your own machine. This directory structure is synchronized with the registry and should not be directly edited. Use Gacutil.exe to manage the assemblies in the GAC.

如果您正在考虑使用选项1或2,请注意,在大多数情况下,它们是一个坏主意,应该避免,除非您使用自己的机器。此目录结构与注册表同步,不应直接编辑。使用Gacutil。exe管理GAC中的程序集。

#1


1  

As Hans Passant at one time had answered, the old GAC is displayed by a shell extension which masks the directory structure. This is to make sure the assemblies in the GAC are managed properly. Opening the directory structure is intentionally not supported. In .NET 4, that is no longer the case so if you can upgrade, that's the way to go.

正如Hans Passant曾经回答的那样,旧的GAC是由一个外壳扩展所显示的,它掩住了目录结构。这是为了确保GAC中的程序集被正确地管理。不支持打开目录结构。在。net 4中,不再是这样了,如果你能升级,那就该走了。

To programmatically open the old GAC there are a few options but again, it is normally masked for a reason. Options:

为了以编程方式打开旧的GAC,有一些选项,但它通常是由于某种原因而被屏蔽的。选项:

  1. Remove the shell extension. You can unregister Shfusion.dll, open the directory, then re-register it. This, of course, could go wrong and leave you with Shfusion.dll permanently unregistered. This would allow other users to freely mess with the GAC directory structure and files which would cause it to become invalid and fall out of sync with the registry = bad.

    删除外壳扩展。你可以注销Shfusion。dll,打开目录,然后重新注册它。当然,这可能会出错,让你陷入混乱。dll永久注册。这将允许其他用户*地使用GAC目录结构和文件,这会导致它变得无效并与注册表不同步。

  2. Disable the shell extension. The HKLM Fusion registry key can have a DisableCacheViewer DWORD value. When set to 1, it will disable the view. The key can be set to 1, the window opened, then the key can be set back to 0. This approach has the same risks as option 1. Additionally, as a user (Damien) whose comment seems to have been deleted pointed out, other processes may also use this global key causing a race condition = bad.

    禁用外壳扩展。HKLM融合注册表键可以有一个DisableCacheViewer DWORD值。当设置为1时,它将禁用视图。可以将密钥设置为1,打开窗口,然后将密钥设置为0。这种方法与选项1具有相同的风险。另外,作为一个用户(Damien)的评论似乎已经被删除了,其他进程也可能使用这个全局键导致一个race条件= bad。

  3. Use a 3rd party application like Total Commander (thanks to Csaba Toth) or Far Manager to view the directory structure instead of Explorer. The downside here is, assuming they can even accept arguments to allow them to open to the GAC directory, it would require installing that software everywhere I want to run my app.

    使用像Total指挥官(感谢Csaba Toth)或Far Manager这样的第三方应用程序来查看目录结构而不是浏览器。这里的缺点是,假设他们甚至可以接受参数来允许他们打开GAC目录,那么在我想运行我的应用程序的任何地方都需要安装这个软件。

If you are considering using options 1 or 2, be aware that in most scenarios they are a bad idea and should be avoided unless you are messing around with your own machine. This directory structure is synchronized with the registry and should not be directly edited. Use Gacutil.exe to manage the assemblies in the GAC.

如果您正在考虑使用选项1或2,请注意,在大多数情况下,它们是一个坏主意,应该避免,除非您使用自己的机器。此目录结构与注册表同步,不应直接编辑。使用Gacutil。exe管理GAC中的程序集。