如何找到所有引用特定dll的程序集? [英] How to find all assemblies that reference a specific dll?
本文介绍了如何找到所有引用特定dll的程序集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的目录中有很多dlls
.我需要找到所有引用特定dll
的内容.
I've a directory with a large number of dlls
. I need to find all those that reference a specific dll
.
我正在考虑以下解决方案:
I'm thinking about the following solution :
- 循环装配并使用
ildasm
调用每个装配
- 将
manifest
转储到文本文件 - 在文本文件中搜索所需的程序集名称.
- Loop the assemblies and invoke each one with
ildasm
- Dump the
manifest
into a text file - Search the text files for the required assembly name.
但是,这种解决方案对我来说是极大的错误.有没有更好的方法来实现呢?
Yet this solution feels immensely wrong to me. Is there a better way to achieve it?
推荐答案
您可以为此目的编写一个小工具,使用Reflection查找引用的程序集:
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
}
}
这篇关于如何找到所有引用特定dll的程序集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文