Getting loaded assemblies for the current AppDomain
:
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
Getting the assemblies referenced by another assembly:
var referencedAssemblies = someAssembly.GetReferencedAssemblies();
Note that if assembly A references assembly B and assembly A is loaded, that does not imply that assembly B is also loaded. Assembly B will only be loaded if and when it is needed. For that reason, GetReferencedAssemblies()
returns AssemblyName
instances rather than Assembly
instances.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…