Get all the dlls for the process

I would like to get a list of all the DLLs loaded for this Process. I am currently using the .NET Framework 4.0 . I know that when trying to access all managed DLLs through the Process.Modules property, an error exists . (Specifies only unmanaged DLLs). I need a way to programmatically get all these dlls.

Process[] myProcess = Process.GetProcessesByName("MyProcess"); if(myProcess.Count() > 0) { foreach (ProcessModule processModule in myProcess[0].Modules) //get information } 

EDIT: The process that interests me is not in the current AppDomain.

+6
source share
1 answer

I know there is a mistake

No, this is not a mistake. This was a deliberate design change in CLR v4, Microsoft did not hide this in secret. Previous versions of the CLR made efforts to emulate loaded assemblies as if they were unmanaged DLLs. But that simply ceased to be clear when they implemented the parallel CLR versioning function on the process side. He left and will not return.

This is not a serious problem, since the list of loaded assemblies in another process is well supported by the debugging interface. ICorDebugAppDomain :: EnumerateAssemblies () is a ticket. Well, not as easy as Process.Modules. Use the MDbg sample to find out how to use it.

+6
source

All Articles