/// <summary> /// /// </summary> protected void LoadModules(PlatformSettings platformSettings) { List <string> loadingModules = new List <string>(); string[] optionalModules = platformSettings.GetString("OptionalModules").Replace("\r", string.Empty).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); loadingModules.AddRange(optionalModules); string[] externalModules = platformSettings.GetString("ExternalModules").Replace("\r", string.Empty).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); loadingModules.AddRange(externalModules); // Load the external optional references for the solution. // Loaded assemblies are attached as runtime references to the main application assembly. foreach (string referenceName in loadingModules) { string filePath = GeneralHelper.MapRelativeFilePathToExecutingDirectory(referenceName); string operationResultMessage = string.Empty; Assembly assembly = null; try { // If you get a *warning* here (LoadFromContext) ignore it. // Using LoadFrom is important, since it will also allow to find // the newly loaded assemblies references, if they are in its folder. assembly = Assembly.LoadFrom(filePath); Type[] types = assembly.GetTypes(); } catch (Exception ex) { operationResultMessage = ex.Message; } if (assembly != null) { ReflectionHelper.AddDynamicReferencedAssembly(Assembly.GetEntryAssembly(), assembly); } else { SystemMonitor.OperationWarning("Failed to load external dynamic module [" + referenceName + ", " + filePath + "; " + operationResultMessage + "]", TracerItem.PriorityEnum.Low); } } //AppDomain.CurrentDomain.DynamicDirectory Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); //AppDomain.CurrentDomain. }
/// <summary> /// /// </summary> protected void LoadModules(PlatformSettings platformSettings) { List<string> loadingModules = new List<string>(); string[] optionalModules = platformSettings.GetString("OptionalModules").Replace("\r", string.Empty).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); loadingModules.AddRange(optionalModules); string[] externalModules = platformSettings.GetString("ExternalModules").Replace("\r", string.Empty).Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); loadingModules.AddRange(externalModules); // Load the external optional references for the solution. // Loaded assemblies are attached as runtime references to the main application assembly. foreach (string referenceName in loadingModules) { string filePath = GeneralHelper.MapRelativeFilePathToExecutingDirectory(referenceName); string operationResultMessage = string.Empty; Assembly assembly = null; try { // If you get a *warning* here (LoadFromContext) ignore it. // Using LoadFrom is important, since it will also allow to find // the newly loaded assemblies references, if they are in its folder. assembly = Assembly.LoadFrom(filePath); Type[] types = assembly.GetTypes(); } catch (Exception ex) { operationResultMessage = ex.Message; } if (assembly != null) { ReflectionHelper.AddDynamicReferencedAssembly(Assembly.GetEntryAssembly(), assembly); } else { SystemMonitor.OperationWarning("Failed to load external dynamic module [" + referenceName + ", " + filePath + "; " + operationResultMessage + "]", TracerItem.PriorityEnum.Low); } } //AppDomain.CurrentDomain.DynamicDirectory Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); //AppDomain.CurrentDomain. }