static void GetAllAssemblies(Assembly start) { AllAssemblies.Add(start.FullName, start); foreach (var item in start.GetReferencedAssemblies()) { try { if (AllAssemblies.ContainsKey(item.FullName)) { continue; } var ass = Assembly.Load(item); GetAllAssemblies(ass); } catch (Exception) { //TODO:log } } }
static AssemblyHelper() { string rootPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var assemblies = Directory.GetFiles(rootPath, "*.dll") .Where(x => !new FileInfo(x).Name.StartsWith("System.") && !new FileInfo(x).Name.StartsWith("Microsoft.")) .Select(x => Assembly.LoadFrom(x)) .Where(x => !x.IsDynamic) .ToList(); assemblies.ForEach(aAssembly => { try { AllTypes.AddRange(aAssembly.GetTypes()); AllAssemblies.Add(aAssembly); } catch { } }); }