.NET Dependency Walker?

  • Thread starter Thread starter Mark A. Richman
  • Start date Start date
M

Mark A. Richman

Does anyone know of a tool, similar to Depends.exe (Dependency Walker) for
..NET assemblies? I'm looking for a way to report on inter-assembly
dependencies. Maybe a Visio plugin that would help map out dependencies
without littering the UI with properties, methods, etc?

Thanks,
Mark
 
Mark A. Richman said:
Does anyone know of a tool, similar to Depends.exe (Dependency Walker) for
.NET assemblies? I'm looking for a way to report on inter-assembly
dependencies. Maybe a Visio plugin that would help map out dependencies
without littering the UI with properties, methods, etc?

Here's a fairly simple thing: give it the name of which
assembly/assemblies you want it to look through. If an entry appears in
square brackets, that means the dependencies for that assembly have
been listed earlier. Let me know if you have any problems with it.

using System;
using System.Reflection;
using System.Collections;

public class DependencyReporter
{
static void Main(string[] args)
{
try
{
if (args.Length==0)
{
Console.WriteLine
("Usage: DependencyReporter <assembly1> [assembly2 ...]");
}

Hashtable alreadyLoaded = new Hashtable();
foreach (string name in args)
{
Assembly assm = Assembly.LoadFrom (name);
DumpAssembly (assm, alreadyLoaded, 0);
}
}
catch (Exception e)
{
Console.WriteLine ("Error: {0}", e.Message);
}
}

static void DumpAssembly (Assembly assm, Hashtable alreadyLoaded,
int indent)
{
Console.Write (new String(' ', indent));
AssemblyName fqn = assm.GetName();
if (alreadyLoaded.Contains(fqn.FullName))
{
Console.WriteLine ("[{0}]", fqn.Name);
return;
}
alreadyLoaded[fqn.FullName]=fqn.FullName;
Console.WriteLine (fqn.Name);

foreach (AssemblyName name in assm.GetReferencedAssemblies())
{
Assembly referenced = Assembly.Load(name);
DumpAssembly(referenced, alreadyLoaded, indent+2);
}
}
}
 
You can use our .NET Explorer to do that. It lists all
managed and unmanaged dependent DLLs, you can also
examine functions in native DLLs.

One tough task is to deal with app.exe.config file, I
have not found any other static tool that handles that.
Our .NET Explorer parses the configuration file, and
determines all DLLs, exactly same as when you run your
app, but those loaded dynamically during runtime may not
appear.

http://www.remotesoft.com/dotexplorer

Load a file, then click Dependency node, right click to
see options.

Huihong
 
Back
Top