Get dependent assemblies?

后端 未结 4 1417
醉梦人生
醉梦人生 2021-02-01 06:48

Is there a way to get all assemblies that depend on a given assembly?

Pseudo:

Assembly a = GetAssembly();
var dependants = a.GetDependants();
         


        
4条回答
  •  一整个雨季
    2021-02-01 07:37

    First define your scope, e.g.:

    1. All assemblies in my application's bin directory

    2. All assemblies in my application's bin directory + all assemblies in the GAC

    3. All assemblies on any machine in the world.

    Then simply (*) iterate through all assemblies in your scope, and use reflection to check if they depend on your target assembly.

    If you want indirect as well as direct references, you'll have to rinse and repeat for all the assemblies you find.

    (*) Might not be quite so simple if your scope is 3 above.

提交回复
热议问题