private static Library GetLibrary(string libName) { var libFName = Path.ChangeExtension(libName, ".dll"); var nameSp = Path.GetFileNameWithoutExtension(libName); var baseClassName = $"{nameSp}.{GREETER_COLLECTION_NAME_SPACE}"; if (libFName == null || nameSp == null) { return(null); } if (Libraries.ContainsKey(nameSp)) { return(Libraries[nameSp]); } var rootDir = AppDomain.CurrentDomain.RelativeSearchPath; var libPath = Path.Combine(rootDir, libFName); if (!File.Exists(libPath)) { return(null); } //загружаем библиотеку try { var assembly = Assembly.LoadFile(libPath); var t = assembly.GetType(baseClassName); var baseObject = (IGreeterLib)t.InvokeMember(null, BindingFlags.CreateInstance, null, null, null); var lib = new Library(baseObject); Libraries.Add(nameSp, lib); return(lib); } catch (Exception e) { throw new IOException("Ошибка при открытии библиотеки репозиториев. \n" + $"Библиотека - \"{libPath}\" \n" + $"Имя класса - \"{baseClassName}\"", e); } }