CSharp examples for System.Reflection:Assembly
Gets all referenced assemblies from current AppDomain, excluding dynamic or Microsoft-specific assemblies. Assemblies will be cached after first call.
using System.Reflection; using System.Linq; using System.Collections.Generic; using System;//from ww w .j a v a2s . c o m public class Main{ /// <summary> /// Gets all referenced assemblies from current AppDomain, excluding dynamic or Microsoft-specific assemblies. /// Assemblies will be cached after first call. /// </summary> /// <returns>All referenced assemblies.</returns> public static IEnumerable<Assembly> GetAssemblies() { if (AllAssemblies.Count == 0) { foreach (var refAsm in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var asm in GetAssemblyAndAllReferencedAssemblies(refAsm)) { if (asm.IsDynamic || asm.FullName.StartsWith("Microsoft.") || asm.FullName.StartsWith("Microsoft,") || asm.FullName.StartsWith("Mono.") || asm.FullName.StartsWith("Mono,") || asm.FullName.StartsWith("System,") || asm.FullName.StartsWith("System.") || asm.FullName.StartsWith("mscorlib") || asm.FullName.StartsWith("Oracle.DataAccess") || asm.FullName.StartsWith("Revenj.DatabasePersistence.Oracle")) continue; if (AssemblyNames.Add(asm.FullName)) AllAssemblies.Add(asm); } } } return AllAssemblies; } }