Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/17/10 16:22:57 (13 years ago)
Author:
swagner
Message:

Fixed exceptions in plugin infrastructure when trying to instantiate types which do not provide a parameterless constructor (#1309).

File:
1 edited

Legend:

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

    r4482 r5131  
    7272    /// <returns>Enumerable of the created instances.</returns>
    7373    public IEnumerable<object> GetInstances(Type type) {
    74       return from t in GetTypes(type, true)
    75              select Activator.CreateInstance(t);
     74      List<object> instances = new List<object>();
     75      foreach (Type t in GetTypes(type, true)) {
     76        object instance = null;
     77        try { instance = Activator.CreateInstance(t); }
     78        catch { }
     79        if (instance != null) instances.Add(instance);
     80      }
     81      return instances;
    7682    }
    7783
Note: See TracChangeset for help on using the changeset viewer.