diff --git a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs b/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs index dcaf4f428..4fbc08b47 100644 --- a/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs +++ b/src/ImageProcessor.Web/NET45/Config/ImageProcessorConfig.cs @@ -17,6 +17,7 @@ namespace ImageProcessor.Web.Config using System.Linq; using System.Reflection; using System.Text; + using System.Web.Compilation; using ImageProcessor.Processors; #endregion @@ -288,21 +289,20 @@ namespace ImageProcessor.Web.Config { if (this.GraphicsProcessors == null) { - try + if (GetImageProcessingSection().Plugins.AutoLoadPlugins) { - if (GetImageProcessingSection().Plugins.AutoLoadPlugins) + Type type = typeof(IGraphicsProcessor); + try { // Build a list of native IGraphicsProcessor instances. - Type type = typeof(IGraphicsProcessor); - IEnumerable types = - AppDomain.CurrentDomain.GetAssemblies() - .SelectMany(s => s.GetTypes()) - .Where(p => type.IsAssignableFrom(p) && p.IsClass && !p.IsAbstract) - .ToList(); - + List availableTypes = BuildManager.GetReferencedAssemblies() + .Cast() + .SelectMany(s => s.GetTypes()) + .Where(t => t != null && type.IsAssignableFrom(t) && t.IsClass && !t.IsAbstract) + .ToList(); + // Create them and add. - this.GraphicsProcessors = - types.Select(x => (Activator.CreateInstance(x) as IGraphicsProcessor)).ToList(); + this.GraphicsProcessors = availableTypes.Select(x => (Activator.CreateInstance(x) as IGraphicsProcessor)).ToList(); // Add the available settings. foreach (IGraphicsProcessor processor in this.GraphicsProcessors) @@ -310,55 +310,46 @@ namespace ImageProcessor.Web.Config processor.Settings = this.GetPluginSettings(processor.GetType().Name); } } - else + catch (ReflectionTypeLoadException ex) { - ImageProcessingSection.PluginElementCollection pluginConfigs = imageProcessingSection.Plugins; - this.GraphicsProcessors = new List(); - foreach (ImageProcessingSection.PluginElement pluginConfig in pluginConfigs) - { - Type type = Type.GetType(pluginConfig.Type); - - if (type == null) - { - throw new ArgumentException("Couldn't load IGraphicsProcessor: " + pluginConfig.Type); - } - - this.GraphicsProcessors.Add(Activator.CreateInstance(type) as IGraphicsProcessor); - } - - // Add the available settings. - foreach (IGraphicsProcessor processor in this.GraphicsProcessors) - { - processor.Settings = this.GetPluginSettings(processor.GetType().Name); - } + this.LoadGraphicsProcessorsFromConfiguration(); } } - catch (ReflectionTypeLoadException ex) + else { - StringBuilder stringBuilder = new StringBuilder(); - foreach (Exception exception in ex.LoaderExceptions) - { - stringBuilder.AppendLine(exception.Message); - if (exception is FileNotFoundException) - { - FileNotFoundException fileNotFoundException = exception as FileNotFoundException; - if (!string.IsNullOrEmpty(fileNotFoundException.FusionLog)) - { - stringBuilder.AppendLine("Fusion Log:"); - stringBuilder.AppendLine(fileNotFoundException.FusionLog); - } - } - - stringBuilder.AppendLine(); - } + this.LoadGraphicsProcessorsFromConfiguration(); + } + } + } - string errorMessage = stringBuilder.ToString(); + /// + /// Loads graphics processors from configuration. + /// + /// + /// Thrown when an cannot be loaded. + /// + private void LoadGraphicsProcessorsFromConfiguration() + { + ImageProcessingSection.PluginElementCollection pluginConfigs = imageProcessingSection.Plugins; + this.GraphicsProcessors = new List(); + foreach (ImageProcessingSection.PluginElement pluginConfig in pluginConfigs) + { + Type type = Type.GetType(pluginConfig.Type); - // Display or log the error based on your application. - throw new Exception(errorMessage); + if (type == null) + { + throw new TypeLoadException("Couldn't load IGraphicsProcessor: " + pluginConfig.Type); } + + this.GraphicsProcessors.Add(Activator.CreateInstance(type) as IGraphicsProcessor); + } + + // Add the available settings. + foreach (IGraphicsProcessor processor in this.GraphicsProcessors) + { + processor.Settings = this.GetPluginSettings(processor.GetType().Name); } } #endregion } -} +} \ No newline at end of file diff --git a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs index bdd85bbbe..cc6158ece 100644 --- a/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs +++ b/src/ImageProcessor.Web/NET45/Properties/AssemblyInfo.cs @@ -31,6 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.1.0.0")] -[assembly: AssemblyFileVersion("3.1.0.0")] - +[assembly: AssemblyVersion("3.1.1.0")] +[assembly: AssemblyFileVersion("3.1.1.0")] \ No newline at end of file diff --git a/src/Nuget/ImageProcessor.Web.3.1.1.0.nupkg b/src/Nuget/ImageProcessor.Web.3.1.1.0.nupkg new file mode 100644 index 000000000..2a8f9ef3b Binary files /dev/null and b/src/Nuget/ImageProcessor.Web.3.1.1.0.nupkg differ