none
How To List All DLLs Loaded By An EXE? RRS feed

  • Question

  • I have a .NET application that connects to a database.  After the application connects you can use Process Explorer to list all DLLs that have been loaded by that executable.  Process Explorer shows you both managed and unmanaged DLLs and their paths.  Programmatically, I would like to be able to list ALL loaded DLLs and specifically take a look at the unmanaged DLLs to see the path in which they are loading from.  This would let me see if the proper DLLs have been loaded by the unmanged database client software that was used to make the connection.  Any help is greatly appreciated!

    Johnson

    • Edited by johnson321 Sunday, October 31, 2010 7:43 PM typo
    Sunday, October 31, 2010 7:40 PM

Answers

  •  

    Hi,

     

    Process.Modules property returns all modules loaded by give process, you can get the path of a module by using the ModuleName property, something like this:

     

                foreach (ProcessModule module in Process.GetCurrentProcess().Modules)

                {

                    Console.WriteLine(module.ModuleName + " -> " + module.FileName);

                }


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by johnson321 Tuesday, November 2, 2010 11:04 PM
    Monday, November 1, 2010 2:34 AM

All replies

  •  

    Hi,

     

    Process.Modules property returns all modules loaded by give process, you can get the path of a module by using the ModuleName property, something like this:

     

                foreach (ProcessModule module in Process.GetCurrentProcess().Modules)

                {

                    Console.WriteLine(module.ModuleName + " -> " + module.FileName);

                }


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by johnson321 Tuesday, November 2, 2010 11:04 PM
    Monday, November 1, 2010 2:34 AM
  • Hi Eric,

    Thanks!  This is exactly what I was looking for!

    Johnson

    Tuesday, November 2, 2010 11:04 PM