How do I determine the dependencies of a .NET application? 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?
相关问题
- Generic Generics in Managed C++
- How to know full paths to DLL's from .csproj f
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
It's funny I had a similar issue and didn't find anything suitable and was aware of good old Dependency Walker so in the end I wrote one myself.
This deals with .NET specifically and will show what references an assembly has (and missing) recursively. It'll also show native library dependencies.
It's free (for personal use) and available here for anyone interested: www.netdepends.com
Feedback welcome.
I find the small utility AsmSpy an invaluable tool to for resolving issues with loading assemblies. It lists all assembly references of managed assemblies including assembly versions.
Run it in a command prompt in the directory of the
.dll
with the following arguments:Install it quickly with Chocolatey:
Open the assembly file in ILDASM and look @ the .assembly extern in the MANIFEST
Try compiling your .NET assembly with the option
--staticlink:"Namespace.Assembly"
. This forces the compiler to pull in all the dependencies at compile time. If it comes across a dependency that's not referenced it will give a warning or error message usually with the name of that assembly.Namespace.Assembly
is the assembly you suspect as having the dependency problem. Typically just statically linking this assembly will reference all dependencies transitively.You don't need to download and install shareware apps or tools. You can do it programitically from .NET using
Assembly.GetReferencedAssemblies()
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.