Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 16:46:35 (12 years ago)
Author:
gkronber
Message:

#1847: merged r8084:8205 from trunk into GP move operators branch

Location:
branches/GP-MoveOperators
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginDescription.cs

    r7259 r8206  
    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;
  • branches/GP-MoveOperators/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs

    r7259 r8206  
    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)
    553                       .Single();
    554 
     558                      .SingleOrDefault();
     559            if (asm == null) throw new InvalidPluginException("Could not load 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.