简体   繁体   English

如何列出所有加载的程序集?

[英]How do I list all loaded assemblies?

In.Net, I would like to enumerate all loaded assemblies over all AppDomains.在.Net 中,我想枚举所有 AppDomains 上的所有加载程序集。 Doing it for my program's AppDomain is easy enough AppDomain.CurrentDomain.GetAssemblies() .为我的程序的 AppDomain 做这件事很容易AppDomain.CurrentDomain.GetAssemblies() Do I need to somehow access every AppDomain?我是否需要以某种方式访问每个 AppDomain? Or is there already a tool that does this?或者是否已经有一个工具可以做到这一点?

Using Visual Studio 使用Visual Studio

  1. Attach a debugger to the process (eg start with debugging or Debug > Attach to process) 将调试器附加到进程(例如,从调试或调试>附加到进程开始)
  2. While debugging, show the Modules window (Debug > Windows > Modules) 在调试时,显示模块窗口(Debug> Windows> Modules)

This gives details about each assembly, app domain and has a few options to load symbols (ie pdb files that contain debug information). 这提供了有关每个程序集,应用程序域的详细信息,并提供了一些加载符号的选项(即包含调试信息的pdb文件)。

在此输入图像描述

Using Process Explorer 使用Process Explorer

If you want an external tool you can use the Process Explorer (freeware, published by Microsoft) 如果您需要外部工具,可以使用Process Explorer (免费软件,由Microsoft发布)

Click on a process and it will show a list with all the assemblies used. 单击一个进程,它将显示包含所有使用的程序集的列表。 The tool is pretty good as it shows other information such as file handles etc. 该工具非常好,因为它显示了其他信息,如文件句柄等。

Programmatically 编程

Check this SO question that explains how to do it. 检查这个解决如何操作的问题。

Here's what I ended up with. 这就是我最终的结果。 It's a listing of all properties and methods, and I listed all parameters for each method. 它是所有属性和方法的列表,我列出了每种方法的所有参数。 I didn't succeed on getting all of the values. 我没有成功获得所有的价值观。

foreach(System.Reflection.AssemblyName an in System.Reflection.Assembly.GetExecutingAssembly().GetReferencedAssemblies()){                      
            System.Reflection.Assembly asm = System.Reflection.Assembly.Load(an.ToString());
            foreach(Type type in asm.GetTypes()){   
                //PROPERTIES
                foreach (System.Reflection.PropertyInfo property in type.GetProperties()){
                    if (property.CanRead){
                        Response.Write("<br>" + an.ToString() + "." + type.ToString() + "." + property.Name);       
                    }
                }
                //METHODS
                var methods = type.GetMethods();
                foreach (System.Reflection.MethodInfo method in methods){               
                    Response.Write("<br><b>" + an.ToString() + "."  + type.ToString() + "." + method.Name  + "</b>");   
                    foreach (System.Reflection.ParameterInfo param in method.GetParameters())
                    {
                        Response.Write("<br><i>Param=" + param.Name.ToString());
                        Response.Write("<br>  Type=" + param.ParameterType.ToString());
                        Response.Write("<br>  Position=" + param.Position.ToString());
                        Response.Write("<br>  Optional=" + param.IsOptional.ToString() + "</i>");
                    }
                }
            }
        }

Using the command prompt cmd.exe you just have to type使用命令提示符cmd.exe ,您只需键入

tasklist /M

in the console and it will list down all the process with all the dll loaded by process.在控制台中,它将列出所有进程以及进程加载的所有dll If that things went too fast in the console you can copy it to clipboard as如果控制台中的事情进行得太快,您可以将其复制到剪贴板

tasklist /M |clip

and paste it to notepad.并将其粘贴到记事本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用CoreClr获取加载的程序集中的所有类型? - How do I get all types in loaded Assemblies with CoreClr? 如何获取所有引用程序集的列表(已加载或未加载) - How to get a list of all referenced assemblies (loaded or not) 如何列出PCL中的所有已加载程序集(可移植类库) - How to list all loaded assemblies in PCL (portable class library) 如何获得可以在计算机上引用的所有程序集的列表? - How do I get a list of all the assemblies I can reference on my machine? 我可以获取当前未加载的程序集的列表吗 - Can I get a list of assemblies that are not currently loaded 如何获取C#中所有已加载类型的列表? - How do I get a list of all loaded Types in C#? 如何获取.NET Compact Framework中所有已加载程序集(引用)的编程列表 - How to get a programmatic list of all loaded assemblies (referenced) in the .NET Compact Framework 在structuremap中,如何扫描程序集并将所有注册添加为单例? - In structuremap, how do I scan assemblies and add all registrations as singletons? 如何从动态加载的程序集中加载包含嵌套类型的泛型类型? - How do I load a generic type containing nested types from dynamically loaded assemblies? 如何在运行时加载的程序集中使用通用log4net引用? - How do I use a common log4net reference in assemblies loaded at runtime?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM