Is there a way to get all assemblies that depend on a given assembly?
Pseudo:
Assembly a = GetAssembly();
var dependants = a.GetDependants();
If you wish to find the dependent assemblies from the current application domain, you could use something like the GetDependentAssemblies
function defined below:
private IEnumerable<Assembly> GetDependentAssemblies(Assembly analyzedAssembly)
{
return AppDomain.CurrentDomain.GetAssemblies()
.Where(a => GetNamesOfAssembliesReferencedBy(a)
.Contains(analyzedAssembly.FullName));
}
public IEnumerable<string> GetNamesOfAssembliesReferencedBy(Assembly assembly)
{
return assembly.GetReferencedAssemblies()
.Select(assemblyName => assemblyName.FullName);
}
The analyzedAssembly
parameter represents the assembly for which you want to find all the dependents.