Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5628


Ignore:
Timestamp:
03/08/11 10:56:06 (14 years ago)
Author:
gkronber
Message:

#1429 Fixed bug in plugin validator which caused an exception because plugins with more than one assembly were disabled twice if the first assembly could not be loaded.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs

    r5445 r5628  
    117117      CheckPluginDependencyCycles(pluginDescriptions);
    118118
    119       // recursively check if all necessary plugins are available and not disabled
    120       // disable plugins with missing or disabled dependencies
     119      // 1st time recursively check if all necessary plugins are available and not disabled
     120      // disable plugins with missing or disabled dependencies
     121      // to prevent that plugins with missing dependencies are loaded into the execution context
     122      // in the next step
    121123      CheckPluginDependencies(pluginDescriptions);
    122124
     
    124126      // disables plugins that are not loaded correctly
    125127      CheckExecutionContextLoad(pluginDescriptions);
     128
     129      // 2nd time recursively check if all necessary plugins have been loaded successfully and not disabled
     130      // disable plugins with for which dependencies could not be loaded successfully
     131      CheckPluginDependencies(pluginDescriptions);
    126132
    127133      // mark all plugins as enabled that were not disabled in CheckPluginFiles, CheckPluginAssemblies,
     
    500506                                                                                .Where(x => x.PluginState != PluginState.Disabled))) {
    501507        foreach (string assemblyLocation in desc.AssemblyLocations) {
    502           try {
    503             // now load the assemblies into the execution context 
    504             // this can still lead to an exception
    505             // even when the assembly was successfully loaded into the reflection only context before
    506             var asm = Assembly.LoadFrom(assemblyLocation);
    507           }
    508           catch (BadImageFormatException) {
    509             desc.Disable(Path.GetFileName(assemblyLocation) + " is not a valid assembly.");
    510           }
    511           catch (FileLoadException) {
    512             desc.Disable("Can't load file " + Path.GetFileName(assemblyLocation));
    513           }
    514           catch (FileNotFoundException) {
    515             desc.Disable("File " + Path.GetFileName(assemblyLocation) + " is missing.");
    516           }
    517           catch (SecurityException) {
    518             desc.Disable("File " + Path.GetFileName(assemblyLocation) + " can't be loaded because of security constraints.");
     508          if (desc.PluginState != PluginState.Disabled) {
     509            try {
     510              // now load the assemblies into the execution context 
     511              // this can still lead to an exception
     512              // even when the assembly was successfully loaded into the reflection only context before
     513              var asm = Assembly.LoadFrom(assemblyLocation);
     514            }
     515            catch (BadImageFormatException) {
     516              desc.Disable(Path.GetFileName(assemblyLocation) + " is not a valid assembly.");
     517            }
     518            catch (FileLoadException) {
     519              desc.Disable("Can't load file " + Path.GetFileName(assemblyLocation));
     520            }
     521            catch (FileNotFoundException) {
     522              desc.Disable("File " + Path.GetFileName(assemblyLocation) + " is missing.");
     523            }
     524            catch (SecurityException) {
     525              desc.Disable("File " + Path.GetFileName(assemblyLocation) + " can't be loaded because of security constraints.");
     526            }
    519527          }
    520528        }
     
    533541          foreach (string assemblyLocation in desc.AssemblyLocations) {
    534542            var asm = (from assembly in assemblies
    535                       where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)
    536                       select assembly)
     543                       where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)
     544                       select assembly)
    537545                      .Single();
    538546
Note: See TracChangeset for help on using the changeset viewer.