Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8193


Ignore:
Timestamp:
07/03/12 13:54:50 (12 years ago)
Author:
gkronber
Message:

#1887 fixed a problem in plugin loading which occurs if one of the assemblies shipped with HeuristicLab is already installed in the GAC of the machine.

Location:
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Manager
Files:
2 edited

Legend:

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

    r7259 r8193  
    139139    }
    140140
     141    /// <summary>
     142    /// Gets and sets the list of assembly names for this plugin. Assembly names are only available after the plugin has been loaded.
     143    /// </summary>
     144    private List<string> assemblyNames;
     145    public IEnumerable<string> AssemblyNames {
     146      get { return assemblyNames; }
     147      set { this.assemblyNames = new List<string>(value); }
     148    }
     149
    141150    internal PluginDescription() {
    142151      pluginState = PluginState.Undefined;
  • trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs

    r8178 r8193  
    506506      foreach (var desc in PluginDescriptionIterator.IterateDependenciesBottomUp(pluginDescriptions
    507507                                                                                .Where(x => x.PluginState != PluginState.Disabled))) {
     508        // store the assembly names so that we can later retrieve the assemblies loaded in the appdomain by name
     509        var assemblyNames = new List<string>();
    508510        foreach (string assemblyLocation in desc.AssemblyLocations) {
    509511          if (desc.PluginState != PluginState.Disabled) {
     
    515517              // this can still lead to an exception
    516518              // even when the assemby was successfully loaded into the reflection only context before
    517               var asm = Assembly.Load(assemblyName);
     519              // when loading the assembly using it's assemblyName it can be loaded from a different location than before (e.g. the GAC)
     520              Assembly.Load(assemblyName);
     521              assemblyNames.Add(assemblyName);
    518522            }
    519523            catch (BadImageFormatException) {
     
    535539          }
    536540        }
     541        desc.AssemblyNames = assemblyNames;
    537542      }
    538543    }
     
    547552        if (desc.PluginState == PluginState.Enabled) {
    548553          // cannot use ApplicationManager to retrieve types because it is not yet instantiated
    549           foreach (string assemblyLocation in desc.AssemblyLocations) {
     554          foreach (string assemblyName in desc.AssemblyNames) {
    550555            var asm = (from assembly in assemblies
    551                        where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)
     556                       where assembly.FullName == assemblyName
    552557                       select assembly)
    553558                      .SingleOrDefault();
    554             if (asm == null) throw new InvalidPluginException("Could not assembly " + assemblyLocation + " for plugin " + desc.Name);
     559            if (asm == null) throw new InvalidPluginException("Could not assembly " + assemblyName + " for plugin " + desc.Name);
    555560            foreach (Type pluginType in asm.GetTypes()) {
    556561              if (typeof(IPlugin).IsAssignableFrom(pluginType) && !pluginType.IsAbstract && !pluginType.IsInterface && !pluginType.HasElementType) {
Note: See TracChangeset for help on using the changeset viewer.