Search code examples
.netwindbgsos

How do I find which assembly could not be loaded by looking at the dump file?


I see this when analyzing my dump file:

0:000> !pe
Exception object: 0000000000ec2228
Exception type:   System.IO.FileNotFoundException
Message:          Could not load file or assembly 'MyTest.exe' or one of its dependencies. The system cannot find the file specified.
InnerException:   <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 80070002

How do I find out which assembly could not be loaded? All I have is this dump file and the condition has resolved since the incident so the app is running fine at the moment.


Solution

  • I suggest using DependencyWalker to find out what assemblies are required and compare that to the list of loaded assemblies (lm).

    Unfortunately the FileNotFoundException is not very helpful regarding details.

    Note that there may be many reasons for an unresolved dependency (this list is not guaranteed to be complete):

    • the DLL does not exist (the obvious)
    • special permissions are required to load the DLL (check NTFS access rights or run the program as administrator)
    • the application is run from a network share which is considered an untrusted location
    • the bitness of the DLL does not match (if that does not result in a BadImageFormatException)
    • a virus scanner is blocking the acces to the file

    You can try to get more information

    • !gle to get details about the last error. This is a native function, so it may give additional insights on what went wrong before the .NET exception happened.
    • look into the Windows event log on the machine where the problem happened. If it's a permission issue, you may find information there
    • look at the output of | to see if it was run from a network share
    • if the problem is reproducible, use Fusion Log Viewer [Stack Overflow] / [MSDN] to find out what's going wrong
    • if the problem is reproducible, use Process Monitor to diagnose, add a filter for your application's executable name. Save the results as XML and push it through ProcMon Analyzer (disclaimer: a free tool written by me)
    • Look at the inner exception(s) - but in your case there aren't any