适用于多台服务器的 GAC 比较工具?

发布于 2024-08-10 08:06:13 字数 127 浏览 4 评论 0原文

有谁知道有一种工具可以让我生成安装到我的网络场中所有服务器上的 .NET GAC 的程序集的报告吗? (30-40 台服务器)

或者,是否有人有通过 WMI、远程注册表查询或其他技术以编程方式访问信息的某种方式的指针或链接?

Does anyone know of a tool that would allow me to generate a report of the assemblies installed to the .NET GAC on all the servers in my web farm? (30-40 servers)

Or alternatively, does anyone have a pointer or a link on some way of accessing the information programmatically, via WMI, or remote registry query, or some other technology?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪之魂 2024-08-17 08:06:13

感谢 Kragen,他暗示在 Explorer 的 GAC 视图的表层之下,存在我可以使用 System.IO 命名空间查询的文件。幸运的是我可以通过网络访问每台服务器。

对于单个程序集,我只需要查询许多服务器上的 GAC 中存在的版本。虽然远不是一个完整的报告应用程序,但这个代码片段很好地满足了我的目的:

private static void QueryServerGAC(string IP)
{
    string rootPath = String.Format(@"\\{0}\C$\WINDOWS\Assembly", IP);
    DirectoryInfo root = new DirectoryInfo(rootPath);

    foreach (DirectoryInfo gacDir in root.GetDirectories("GAC*")) // GAC, GAC_32, GAC_MSIL
    {
        foreach (DirectoryInfo assemDir in gacDir.GetDirectories("MyAssemblyName"))
        {
            foreach (DirectoryInfo versionDir in assemDir.GetDirectories())
            {
                string assemVersion = versionDir.Name.Substring(0, versionDir.Name.IndexOf('_'));
                foreach (FileInfo fi in versionDir.GetFiles("*.dll"))
                {
                    FileVersionInfo vi = FileVersionInfo.GetVersionInfo(fi.FullName);
                    Console.WriteLine("{0}\t{1}\t{2}\t{3}", IP, fi.Name, assemVersion, vi.FileVersion);
                }
            }
        }
    }
}

可以为每个感兴趣的服务器 IP 调用一次,并将 IP、DLL 名称、程序集版本和文件版本打印到控制台。

请随意使用此代码并根据您自己的目的进行修改。

Thanks Kragen, for hinting that beneath the veneer of Explorer's GAC view, there existed files I could query with the System.IO namespace. Luckily I have network access to each server.

I just needed, for a single assembly, to query the versions that existed in the GAC on many servers. While far from a complete reporting application, this snippet served my purposes nicely:

private static void QueryServerGAC(string IP)
{
    string rootPath = String.Format(@"\\{0}\C$\WINDOWS\Assembly", IP);
    DirectoryInfo root = new DirectoryInfo(rootPath);

    foreach (DirectoryInfo gacDir in root.GetDirectories("GAC*")) // GAC, GAC_32, GAC_MSIL
    {
        foreach (DirectoryInfo assemDir in gacDir.GetDirectories("MyAssemblyName"))
        {
            foreach (DirectoryInfo versionDir in assemDir.GetDirectories())
            {
                string assemVersion = versionDir.Name.Substring(0, versionDir.Name.IndexOf('_'));
                foreach (FileInfo fi in versionDir.GetFiles("*.dll"))
                {
                    FileVersionInfo vi = FileVersionInfo.GetVersionInfo(fi.FullName);
                    Console.WriteLine("{0}\t{1}\t{2}\t{3}", IP, fi.Name, assemVersion, vi.FileVersion);
                }
            }
        }
    }
}

This can be called once for each server IP of interest, and prints the IP, DLL Name, Assembly Version, and FileVersion to the console.

Feel free to take this code and modify for your own purposes.

好听的两个字的网名 2024-08-17 08:06:13

您可以禁用默认的 GAC 视图,将其变成注册表中的普通资源管理器视图,只需将以下值设置为 1:(

HKEY_LOCAL_MACHINE\Software\Microsoft\Fusion\

来源 http://sqlmusings.wordpress.com/2007/11/17/how-to-disable-gac-view/

您然后可以使用一些文件夹比较工具,或者只是从文件夹名称中找出存在哪些程序集。

仅供参考 - 这只是关闭资源管理器视图,但是与文件系统的其他交互点(例如 C# 中的文件对象或命令提示符)已经看到此视图,因此可能不需要在所有文件系统上设置此注册表项你的服务器。

You can disable the default GAC view to turn it into a normal explorer view in the registry, just set the following value to 1:

HKEY_LOCAL_MACHINE\Software\Microsoft\Fusion\

(Source http://sqlmusings.wordpress.com/2007/11/17/how-to-disable-gac-view/)

You can then just use some folder comparison tool, or just work out what assemblies are present from the folder names.

FYI - this just turns off the explorer view, however other points of interaction with the filesystem (e.g. the File object in C#, or the command prompt) already see this view, so there probably isnt any need to set this registry key on all of your servers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文