/// <summary> /// /// </summary> /// <param name="baseDir"></param> /// <returns></returns> private static List <Inf> GetUpdateInfos(DirectoryInfo baseDir) { List <Inf> list = new List <Inf>(); FileInfo[] files = baseDir.GetFiles(); foreach (FileInfo file in files) { if (!string.Equals(".dll", file.Extension, StringComparison.OrdinalIgnoreCase) && !string.Equals(".exe", file.Extension, StringComparison.OrdinalIgnoreCase)) { continue; } try { Assembly ass = Assembly.LoadFrom(file.FullName); Type[] types = ass.GetTypes(); foreach (Type type in types) { try { if (!type.IsAbstract) { if (typeof(IUpdateInfo).IsAssignableFrom(type)) { IUpdateInfo ui = ass.CreateInstance(type.FullName) as IUpdateInfo; if (ui != null && !string.IsNullOrEmpty(ui.UpdateInfoURL)) { list.Add(new Inf(ui.GetType().Assembly.GetName().Name, ui.UpdateInfoURL, ass.GetName().Version)); } } } } catch (Exception) { } } } catch (ReflectionTypeLoadException rte) { foreach (Type type in rte.Types) { try { if (!type.IsAbstract) { if (typeof(IUpdateInfo).IsAssignableFrom(type)) { IUpdateInfo ui = type.Assembly.CreateInstance(type.FullName) as IUpdateInfo; if (ui != null && !string.IsNullOrEmpty(ui.UpdateInfoURL)) { list.Add(new Inf(ui.GetType().Assembly.GetName().Name, ui.UpdateInfoURL, type.Assembly.GetName().Version)); } } } } catch (Exception) { } } } catch (Exception) { } } return(list); }