469,902 Members | 1,948 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,902 developers. It's quick & easy.

.NET Dependency Walker?

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
Jul 21 '05 #1
2 17875
Mark A. Richman <no****@nospam.com> wrote:
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);
}
}
}

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
Reflector: http://www.aisto.com/roeder/dotnet/
--
____________________
Klaus H. Probst, MVP
http://www.vbbox.com/

"Mark A. Richman" <no****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by mike | last post: by
2 posts views Thread by Chris Capel | last post: by
1 post views Thread by Bruno van Dooren | last post: by
2 posts views Thread by Mark A. Richman | last post: by
1 post views Thread by cartoper | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.