How to find all assemblies that reference a specific dll?

馋奶兔 提交于 2019-12-06 05:04:44

You could write a small tool for that purpose, using Reflection to find the referenced assemblies:

string[] fileNames = ...; // get all the filenames
foreach (string fileName in fileNames) {
    var assembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom(fileName);
    var referencedAssemblies = assembly.GetReferencedAssemblies();

    foreach (var assemblyName in referencedAssemblies) {
        // do your comparison
    }
}

According to Microsoft documentationnn AppDomain.CurrentDomain.GetAssemblies() Gets the assemblies that have been loaded into the execution context of this application domain. About AppDomain.CurrentDomain.GetAssemblies()

It seems that you need to change strategy of loading the asseblies you need from using the appdomain to looking for dlls in your applications folder.

I found a discuss on similar problem here

Download AsmSpy.exe, it has the option to list all assemblies and all the references within the assemblies.

https://github.com/mikehadlow/AsmSpy

Download IlSpy.exe, and open the assembly whose references you want to see, it will list all referenced assemblies.

https://github.com/icsharpcode/ILSpy/releases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!