Changeset 8193
- Timestamp:
- 07/03/12 13:54:50 (12 years ago)
- 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 139 139 } 140 140 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 141 150 internal PluginDescription() { 142 151 pluginState = PluginState.Undefined; -
trunk/sources/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs
r8178 r8193 506 506 foreach (var desc in PluginDescriptionIterator.IterateDependenciesBottomUp(pluginDescriptions 507 507 .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>(); 508 510 foreach (string assemblyLocation in desc.AssemblyLocations) { 509 511 if (desc.PluginState != PluginState.Disabled) { … … 515 517 // this can still lead to an exception 516 518 // 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); 518 522 } 519 523 catch (BadImageFormatException) { … … 535 539 } 536 540 } 541 desc.AssemblyNames = assemblyNames; 537 542 } 538 543 } … … 547 552 if (desc.PluginState == PluginState.Enabled) { 548 553 // cannot use ApplicationManager to retrieve types because it is not yet instantiated 549 foreach (string assembly Location in desc.AssemblyLocations) {554 foreach (string assemblyName in desc.AssemblyNames) { 550 555 var asm = (from assembly in assemblies 551 where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)556 where assembly.FullName == assemblyName 552 557 select assembly) 553 558 .SingleOrDefault(); 554 if (asm == null) throw new InvalidPluginException("Could not assembly " + assembly Location+ " for plugin " + desc.Name);559 if (asm == null) throw new InvalidPluginException("Could not assembly " + assemblyName + " for plugin " + desc.Name); 555 560 foreach (Type pluginType in asm.GetTypes()) { 556 561 if (typeof(IPlugin).IsAssignableFrom(pluginType) && !pluginType.IsAbstract && !pluginType.IsInterface && !pluginType.HasElementType) {
Note: See TracChangeset
for help on using the changeset viewer.