views:

2545

answers:

7

Does Dependency Walker work with managed apps? I've downloaded the latest and tried profiling the app, but it just exits without much of an explanation. If it doesn't work with .NET, then is there some other tool that would help me debug a run-time DLL loading issue?

A: 

It will work, however you will find it not very useful

bashmohandes
+9  A: 

Dependency walker works on normal win32 binaries. All .NET dll's and exe's have a small stub header part which makes them look like normal binaries, but all it basically says is "load the CLR" - so that's all that dependency walker will tell you.

To see which things your .NET app actually relies on, you can use the tremendously excellent .NET reflector from red gate.

Load your DLL into it, right click, and chose 'Analyze' - you'll then see a "Depends On" item which will show you all the other dll's (and methods inside those dll's) that it needs.

It can sometimes get trickier though, in that your app depends on X dll, and X dll is present, but for whatever reason can't be loaded or located at runtime.

To troubleshoot those kinds of issues, Microsoft have an Assembly Binding Log Viewer which can show you what's going on at runtime

Orion Edwards
I think you missed a little of that URL - the .aspx got put in the link text. I managed to find it though.
Brian Stewart
oh... yeah the markdown control eats brackets in URL's, and unfortunately MSDN puts (VS80) in all it's url's :-(
Orion Edwards
A: 

Thanks Orion, I managed to find the Assembly Binding Log Viewer, but nothing shows up in the viewer, even when I set it to "Log all binds to disk", even after re-running my app. Is there something else I need to do to get binding information to show up in the log? I should add that the View Log button is disabled for some reason.

Brian Stewart
+2  A: 

Enable assembly binding logging set the registry value EnableLog in HKLM\Software\Microsoft\Fusion to 1. Note that you have to restart your application (use iisreset) for the changes to have any effect.

Tip: Remember to turn off fusion logging when you are done since there is a performance penalty to have it turned on.

Ramesh
+1  A: 

It appears that there is a bug with the Assembly Binding Log Viewer, which keeps it from displaying any entries if there are a certain number (too many?) files in the IE temp cache folder. I purge my cache, and it works fine. Here's the post I found on the topic. I didn't have to change that registry value, it appears that the settings behind the Settings button do that for you.

Brian Stewart
+5  A: 

To do static dependencies evaluation of .NET code, you can use the tool NDepend. It comes with a dependency matrix, some graph and also a language dedicated to get information from your code base. See more info here.

Patrick Smacchia - NDepend dev
Patrick should probably have mentioned he's the author of that fantastic tool ;). It's really worth checking out. +1 for writing it!
Mitch Wheat
Hey, I just noticed this myself. I enjoy reading his blog posts - I'll have to try out NDepend!
Brian Stewart
A: 

Another handy Reflector add-in that I use is the Dependency Structure Matrix. It's really great to see what classes use what. Plus it's free.

Richard Morgan