CSharp examples for System.Reflection:Assembly
Get Loaded Assemblies
using System.Reflection; using System.Linq; using System.IO;// w ww. j av a 2s. c o m using System.Diagnostics; using System.Collections.Generic; using System; public class Main{ private static Dictionary<string, Assembly> GetLoadedAssemblies(string assemblyPrefix) { return AppDomain.CurrentDomain .GetAssemblies() .Where<Assembly>(a => a.FullName.StartsWith(assemblyPrefix)).ToDictionary<Assembly, string>(a => a.GetName().Name); } public static IEnumerable<Assembly> GetAssemblies(string assemblyPrefix) { IEnumerable<Assembly> assemblies; if (string.IsNullOrWhiteSpace(assemblyPrefix)) assemblies = AppDomain.CurrentDomain.GetAssemblies().AsEnumerable(); else assemblies = AppDomain.CurrentDomain.GetAssemblies() .Where<Assembly>(a => a.FullName.StartsWith(assemblyPrefix)); return assemblies; } }