Click here to Skip to main content
11,490,266 members (54,079 online)
Click here to Skip to main content

Dll Profiler in C#

, 29 Apr 2003 165.3K 2.4K 55
Rate this:
Please Sign up or sign in to vote.
A debugging tool for applications using multiple DLLs.

All Process and their loaded DLLs informations

Picture 1.All Process and its loaded DLLs information.

Filter against process name

Picture 2. Filter against process name.

Start a new application

Picture 3. Start a new application.

Stop a running application

Picture 4. Stop a running application.

Overview

In your computer, there may be thousands of versions of a DLL. Which version are you using? Which DLL has effectively been loaded by your effectively been loaded by your application? You must check the path, version and the current working directory of your process, etc. If you want to answer quickly, use DLL Profiler.

DLL profiler is used list all the DLLs that are currently loaded in your machine, including where they are loaded and their version number, size, modification date, product name and product version. It's an application used to find the multiple DLLs error if you start an application.

Moreover, you can start and stop an application directly here and watch it's loaded DLLs and their errors.

You can search loaded DLLs against one process only. DLL Profiler is having filter facility to look at a particular process' DLLs only.

This class demonstrates the use of following namespaces.

  • System.IO
  • System.Net
  • System.Diagnostics
  • System.Threading
  • System.Drawing.Drawing2D
  • Logger

Installation step

Just download and click an exe to run the application.

Source code

Have you ever experienced an error while loading a DLL when you start an application? Invalid DLL version? or ???

If so, It's for you.

If you want to monitor your application after you open it. You can use this.

The main idea is get all the processes running in local machine. And get all modules and appropriate details like module path, file version, file size, file modification date, file description, product name and product version.

using System;
using System.Data;
using System.Drawing;
using System.IO;
using System.Collections;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;
using Logger;

The above namespaces are must for DLL Profiler. Here, I have placed the code to reveal to you how to get running process' name and process ID.

//Get all processes

Process[] procList =  Process.GetProcesses(); 

for ( int i=0; i<procList.Length; i++) 
{ 

     MessgeBox.Show("Process Id=" +  procList[i].Id + 
           "\t" + " Process Name=" + procList[i].ProcessName); 

}

The following code will explain how to get modules/DLLs for appropriate process.

//Get all modules inside the process
Process[] ObjModulesList = Process.GetProcessesByName("devenv");

// Populate the module collection.
ProcessModuleCollection ObjModules = ObjModulesList[0].Modules;

// Iterate through the module collection.
foreach (ProcessModule objModule in ObjModules)
{
//Get valid module path
strModulePath =GetValidString(objModule.FileName.ToString());
//If the module exists
if (File.Exists(objModule.FileName.ToString()))
  {
    //Get version
    string strFileVersion = GetValidString(objModule.
                  FileVersionInfo.FileVersion.ToString()); 
    //Get File size
    string strFileSize    = GetValidString
                (objModule.ModuleMemorySize.ToString());
    //Get Modification date
    FileInfo objFileInfo = new 
                FileInfo(objModule.FileName.ToString());
    string strFileModificationDate = GetValidString
         (objFileInfo.LastWriteTime.ToShortDateString());  
    //Get File description
    string strFileDescription  = GetValidString
                  (objModule.FileVersionInfo.
                  FileDescription.ToString()); 
    //Get Product Name
    string strProductName  = GetValidString
           (objModule.FileVersionInfo.ProductName.ToString());
    //Get Product Version
    string strProductVersion  = GetValidString
          (objModule.FileVersionInfo.ProductVersion.ToString());
  }
}

Start and stop an application

START an Application

//Create a new process
Process myProcess = new Process();

//Process name notepad
myProcess.StartInfo.FileName = "Notepad";

//Set it's window style maximized
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;

//Start an exe
myProcess.Start();

STOP an Application

// Returns array containing all instances of Notepad.
Process[] myProcesses = Process.GetProcessesByName("Notepad");

foreach(Process myProcess in myProcesses){
    myProcess.CloseMainWindow();
}

To use this class, Just add a reference to your project and follow the steps and just import the Logger reference into you project

Logging

I have used Logger here. You can use on/off logging remove as you like. People who don't know about Logger Please visit Logger in C# - An easy way for monitoring .NET applications

Moreover, If you look at this project you can get the following ideas:

  1. Splash screen
  2. Toolbar
  3. Coloring particular row depends on value in DataGrid.
  4. Run and stop an application through program.

That's all.

I would like to hear your opinion. Thanks in advance.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Ashraf Mohamed
Web Developer
United States United States
I am a system analyst and have been with Microsoft & Sun Technologies for more than 7 years. I have always been fascinated by java and .NET. I take lot of technical articles and writing them.

I am a Sun Certified Java Programmer for Java 2 Platform 1.4 , Web component developer Java 2 Platform - Enterprise Edition 1.4 and Microsoft certified developer using C#.NET in Web Development ASP.NET.

Visit my web site www.mohamedashraf.tk

Comments and Discussions

 
QuestionI removed Logger and all lines with ErrorLog, but program won't start Pin
ancich26-Nov-14 4:01
memberancich26-Nov-14 4:01 
Question.Net Framework 3.5 test Pin
charlyatx31-Oct-13 10:27
membercharlyatx31-Oct-13 10:27 
QuestionRemote Hosts Pin
ewnolen18-Mar-09 8:45
memberewnolen18-Mar-09 8:45 
Questionhelp needed Pin
ummer2615-Feb-09 8:05
memberummer2615-Feb-09 8:05 
AnswerRe: help needed Pin
Ashraf Mohamed15-Feb-09 19:11
memberAshraf Mohamed15-Feb-09 19:11 
GeneralRe: help needed Pin
ummer2616-Feb-09 2:25
memberummer2616-Feb-09 2:25 
GeneralRe: help needed Pin
Ashraf Mohamed16-Feb-09 6:00
memberAshraf Mohamed16-Feb-09 6:00 
Hi,

Please investigate why this is occured? atleast send me the snippet of the code.

I hope u might have missed something.

- Ashraf Mohamed

visit www.mohamedashraf.tk

GeneralRe: help needed Pin
ummer2616-Feb-09 7:22
memberummer2616-Feb-09 7:22 
GeneralRe: help needed Pin
ummer2617-Feb-09 21:02
memberummer2617-Feb-09 21:02 
GeneralNOT Working Pin
Sachin Dubey13-Aug-08 4:11
memberSachin Dubey13-Aug-08 4:11 
GeneralRe: NOT Working Pin
Ashraf Mohamed13-Aug-08 18:55
memberAshraf Mohamed13-Aug-08 18:55 
Questionenumeration is slow Pin
hk1122-Jun-07 20:05
memberhk1122-Jun-07 20:05 
AnswerRe: enumeration is slow Pin
Mohamed Ashraf25-Jun-07 20:41
memberMohamed Ashraf25-Jun-07 20:41 
GeneralReference Pin
nclauder30-Jan-07 20:53
membernclauder30-Jan-07 20:53 
GeneralRe: Reference Pin
Mohamed Ashraf13-Feb-07 0:18
memberMohamed Ashraf13-Feb-07 0:18 
GeneralRe: Reference Pin
nclauder13-Feb-07 19:16
membernclauder13-Feb-07 19:16 
General, Pin
nclauder30-Jan-07 20:44
membernclauder30-Jan-07 20:44 
GeneralException Pin
Ihor Bobak20-Jan-06 10:14
memberIhor Bobak20-Jan-06 10:14 
GeneralDetecting Hidden Processes Pin
ducspam19-Oct-05 9:55
memberducspam19-Oct-05 9:55 
GeneralError msg when opening dllprofiler Pin
easy57818-Feb-05 7:13
membereasy57818-Feb-05 7:13 
GeneralRe: Error msg when opening dllprofiler Pin
Anonymous20-Feb-05 20:32
sussAnonymous20-Feb-05 20:32 
GeneralRe: Error msg when opening dllprofiler Pin
tracernet_v212-Apr-07 20:21
membertracernet_v212-Apr-07 20:21 
GeneralC Pin
luc@vasco27-Sep-04 22:23
memberluc@vasco27-Sep-04 22:23 
GeneralExtensible Performance Counters Pin
Anonymous14-Dec-03 0:50
sussAnonymous14-Dec-03 0:50 
GeneralRe: Extensible Performance Counters Pin
Mohamed Ashraf31-Aug-04 23:32
memberMohamed Ashraf31-Aug-04 23:32 
GeneralComboBox should be cleared upon Refresh Pin
skinnyriz16-Oct-03 6:34
memberskinnyriz16-Oct-03 6:34 
GeneralKilling all processes running under a specific user Pin
aadilch13-Jun-03 8:00
memberaadilch13-Jun-03 8:00 
GeneralNeed your help Pin
bakaragain10-May-03 11:30
memberbakaragain10-May-03 11:30 
Generaldo you have ever deal with device driver Pin
bakaragain9-May-03 5:57
memberbakaragain9-May-03 5:57 
GeneralRe: do you have ever deal with device driver Pin
Mohamed Ashraf9-May-03 19:01
memberMohamed Ashraf9-May-03 19:01 
Generali have a question Pin
bakaragain7-May-03 21:58
memberbakaragain7-May-03 21:58 
GeneralRe: i have a question Pin
Mohamed Ashraf8-May-03 2:55
memberMohamed Ashraf8-May-03 2:55 
GeneralRe: i have a question Pin
Anonymous9-May-03 5:47
sussAnonymous9-May-03 5:47 
GeneralNeeds some clean-up Pin
onc22-Apr-03 5:11
memberonc22-Apr-03 5:11 
GeneralRe: Needs some clean-up Pin
Mohamed Ashraf23-Apr-03 2:32
memberMohamed Ashraf23-Apr-03 2:32 
GeneralBug Fixed Pin
Mohamed Ashraf30-Apr-03 3:10
memberMohamed Ashraf30-Apr-03 3:10 
GeneralThis is not a profiler... Pin
leppie20-Apr-03 2:16
memberleppie20-Apr-03 2:16 
GeneralRe: This is not a profiler... Pin
Mohamed Ashraf20-Apr-03 19:08
memberMohamed Ashraf20-Apr-03 19:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150520.1 | Last Updated 30 Apr 2003
Article Copyright 2003 by Ashraf Mohamed
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid