Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/ApplicationBase.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/ApplicationBase.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/ApplicationBase.cs	(revision 13341)
@@ -0,0 +1,73 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+namespace HeuristicLab.PluginInfrastructure {
+  /// <summary>
+  /// Abstract base implementation for the IApplication interface.
+  /// </summary>
+  public abstract class ApplicationBase : IApplication {
+    /// <summary>
+    /// Initializes a new instance of <see cref="ApplicationBase"/>.
+    /// </summary>
+    protected ApplicationBase() { }
+
+    private ApplicationAttribute ApplicationAttribute {
+      get {
+        object[] appAttributes = this.GetType().GetCustomAttributes(typeof(ApplicationAttribute), false);
+
+        // exactly one attribute of the type ClassInfoAttribute must be given
+        if (appAttributes.Length == 0) {
+          throw new InvalidPluginException("ApplicationAttribute on type " + this.GetType() + " is missing.");
+        } else if (appAttributes.Length > 1) {
+          throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + this.GetType());
+        }
+
+        return (ApplicationAttribute)appAttributes[0];
+      }
+    }
+
+    #region IApplication Members
+
+    /// <summary>
+    /// Gets the name of the application.
+    /// </summary>
+    public string Name {
+      get { return ApplicationAttribute.Name; }
+    }
+
+    /// <summary>
+    /// Gets the description of the application.
+    /// </summary>
+    public string Description {
+      get {
+        return ApplicationAttribute.Description;
+      }
+    }
+
+    /// <summary>
+    /// Runs the application.
+    /// </summary>
+    public abstract void Run(ICommandLineArgument[] args);
+
+    #endregion
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/ApplicationDescription.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/ApplicationDescription.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/ApplicationDescription.cs	(revision 13341)
@@ -0,0 +1,89 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+
+namespace HeuristicLab.PluginInfrastructure.Manager {
+  /// <summary>
+  /// Class that provides information about an application.
+  /// </summary>
+  [Serializable]
+  public sealed class ApplicationDescription : IApplicationDescription {
+    private string name;
+
+    /// <summary>
+    /// Gets or sets the name of the application.
+    /// </summary>
+    public string Name {
+      get { return name; }
+      internal set { name = value; }
+    }
+    private Version version;
+
+    /// <summary>
+    /// Gets or sets the version of the application.
+    /// </summary>
+    public Version Version {
+      get { return version; }
+      internal set { version = value; }
+    }
+    private string description;
+
+    /// <summary>
+    /// Gets or sets the description of the application.
+    /// </summary>
+    public string Description {
+      get { return description; }
+      internal set { description = value; }
+    }
+
+    private bool autoRestart;
+    /// <summary>
+    /// Gets or sets the boolean flag if the application should be automatically restarted.
+    /// </summary>
+    public bool AutoRestart {
+      get { return autoRestart; }
+      internal set { autoRestart = value; }
+    }
+
+    private string declaringAssemblyName;
+    /// <summary>
+    /// Gets or sets the name of the assembly that contains the IApplication type.
+    /// </summary>
+    public string DeclaringAssemblyName {
+      get { return declaringAssemblyName; }
+      internal set { declaringAssemblyName = value; }
+    }
+
+    private string declaringTypeName;
+    /// <summary>
+    /// Gets or sets the name of the type that implements the interface IApplication.
+    /// </summary>
+    public string DeclaringTypeName {
+      get { return declaringTypeName; }
+      internal set { declaringTypeName = value; }
+    }
+
+    public override string ToString() {
+      return Name + " " + Version;
+    }
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/BaseClasses/ApplicationBase.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/BaseClasses/ApplicationBase.cs	(revision 13340)
+++ 	(revision )
@@ -1,73 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-
-namespace HeuristicLab.PluginInfrastructure {
-  /// <summary>
-  /// Abstract base implementation for the IApplication interface.
-  /// </summary>
-  public abstract class ApplicationBase : IApplication {
-    /// <summary>
-    /// Initializes a new instance of <see cref="ApplicationBase"/>.
-    /// </summary>
-    protected ApplicationBase() { }
-
-    private ApplicationAttribute ApplicationAttribute {
-      get {
-        object[] appAttributes = this.GetType().GetCustomAttributes(typeof(ApplicationAttribute), false);
-
-        // exactly one attribute of the type ClassInfoAttribute must be given
-        if (appAttributes.Length == 0) {
-          throw new InvalidPluginException("ApplicationAttribute on type " + this.GetType() + " is missing.");
-        } else if (appAttributes.Length > 1) {
-          throw new InvalidPluginException("Found multiple ApplicationAttributes on type " + this.GetType());
-        }
-
-        return (ApplicationAttribute)appAttributes[0];
-      }
-    }
-
-    #region IApplication Members
-
-    /// <summary>
-    /// Gets the name of the application.
-    /// </summary>
-    public string Name {
-      get { return ApplicationAttribute.Name; }
-    }
-
-    /// <summary>
-    /// Gets the description of the application.
-    /// </summary>
-    public string Description {
-      get {
-        return ApplicationAttribute.Description;
-      }
-    }
-
-    /// <summary>
-    /// Runs the application.
-    /// </summary>
-    public abstract void Run(ICommandLineArgument[] args);
-
-    #endregion
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/BaseClasses/PluginBase.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/BaseClasses/PluginBase.cs	(revision 13340)
+++ 	(revision )
@@ -1,61 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-
-namespace HeuristicLab.PluginInfrastructure {
-  /// <summary>
-  /// Abstract base implementation of the IPlugin interface.
-  /// </summary>
-  public abstract class PluginBase : IPlugin {
-    /// <summary>
-    /// Initializes a new instance of <see cref="PluginBase"/>.
-    /// </summary>
-    protected PluginBase() { }
-
-    private PluginAttribute PluginAttribute {
-      get {
-        object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginAttribute), false);
-        // exactly one attribute of the type PluginDescriptionAttribute must be given
-        if (pluginAttributes.Length == 0) {
-          throw new InvalidPluginException("PluginAttribute on type " + this.GetType() + " is missing.");
-        } else if (pluginAttributes.Length > 1) {
-          throw new InvalidPluginException("Found multiple PluginAttributes on type " + this.GetType());
-        }
-        return (PluginAttribute)pluginAttributes[0];
-      }
-    }
-
-    #region IPlugin Members
-    /// <inheritdoc />
-    public string Name {
-      get {
-        return PluginAttribute.Name;
-      }
-    }
-
-    /// <inhertitdoc />
-    public virtual void OnLoad() { }
-    /// <inhertitdoc />
-    public virtual void OnUnload() { }
-    #endregion
-
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj	(revision 13340)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/HeuristicLab.PluginInfrastructure-3.3.csproj	(revision 13341)
@@ -112,4 +112,6 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="ApplicationBase.cs" />
+    <Compile Include="ApplicationDescription.cs" />
     <Compile Include="AssemblyExtensions.cs" />
     <Compile Include="CommandLineArgumentHandling\Arguments\OpenArgument.cs" />
@@ -125,6 +127,10 @@
     <Compile Include="Attributes\PluginDependencyAttribute.cs" />
     <Compile Include="Attributes\PluginFileAttribute.cs" />
-    <Compile Include="BaseClasses\ApplicationBase.cs" />
-    <Compile Include="BaseClasses\PluginBase.cs" />
+    <Compile Include="PluginBase.cs" />
+    <Compile Include="PluginDescription.cs" />
+    <Compile Include="PluginFile.cs" />
+    <Compile Include="PluginInfrastructureEventArgs.cs" />
+    <Compile Include="PluginManager.cs" />
+    <Compile Include="PluginValidator.cs" />
     <Compile Include="SandboxApplicationManager.cs" />
     <Compile Include="DefaultApplicationManager.cs" />
@@ -138,17 +144,9 @@
     <Compile Include="Interfaces\IPluginDescription.cs" />
     <Compile Include="InvalidPluginException.cs" />
-    <Compile Include="Manager\ApplicationDescription.cs" />
-    <Compile Include="Manager\PluginFile.cs" />
-    <Compile Include="Manager\PluginDescription.cs" />
-    <Compile Include="Manager\PluginInfrastructureEventArgs.cs" />
-    <Compile Include="Manager\PluginManager.cs" />
-    <Compile Include="Manager\PluginValidator.cs" />
     <Compile Include="PluginDescriptionIterator.cs" />
     <Compile Include="ApplicationManager.cs" />
     <Compile Include="PluginState.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Sandboxing\SandboxManager.cs">
-      <SubType>Code</SubType>
-    </Compile>
+    <Compile Include="SandboxManager.cs" />
     <Compile Include="TypeExtensions.cs" />
     <None Include="app.config">
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/ApplicationDescription.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/ApplicationDescription.cs	(revision 13340)
+++ 	(revision )
@@ -1,89 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-
-namespace HeuristicLab.PluginInfrastructure.Manager {
-  /// <summary>
-  /// Class that provides information about an application.
-  /// </summary>
-  [Serializable]
-  public sealed class ApplicationDescription : IApplicationDescription {
-    private string name;
-
-    /// <summary>
-    /// Gets or sets the name of the application.
-    /// </summary>
-    public string Name {
-      get { return name; }
-      internal set { name = value; }
-    }
-    private Version version;
-
-    /// <summary>
-    /// Gets or sets the version of the application.
-    /// </summary>
-    public Version Version {
-      get { return version; }
-      internal set { version = value; }
-    }
-    private string description;
-
-    /// <summary>
-    /// Gets or sets the description of the application.
-    /// </summary>
-    public string Description {
-      get { return description; }
-      internal set { description = value; }
-    }
-
-    private bool autoRestart;
-    /// <summary>
-    /// Gets or sets the boolean flag if the application should be automatically restarted.
-    /// </summary>
-    public bool AutoRestart {
-      get { return autoRestart; }
-      internal set { autoRestart = value; }
-    }
-
-    private string declaringAssemblyName;
-    /// <summary>
-    /// Gets or sets the name of the assembly that contains the IApplication type.
-    /// </summary>
-    public string DeclaringAssemblyName {
-      get { return declaringAssemblyName; }
-      internal set { declaringAssemblyName = value; }
-    }
-
-    private string declaringTypeName;
-    /// <summary>
-    /// Gets or sets the name of the type that implements the interface IApplication.
-    /// </summary>
-    public string DeclaringTypeName {
-      get { return declaringTypeName; }
-      internal set { declaringTypeName = value; }
-    }
-
-    public override string ToString() {
-      return Name + " " + Version;
-    }
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginDescription.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginDescription.cs	(revision 13340)
+++ 	(revision )
@@ -1,213 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace HeuristicLab.PluginInfrastructure.Manager {
-  /// <summary>
-  /// Holds information of loaded plugins that is needed for plugin management.
-  /// Used to represent plugins in AppDomains without loading the plugin assemblies.
-  /// </summary>
-  [Serializable]
-  public sealed class PluginDescription : IPluginDescription {
-    private int nTimesLoaded;
-
-    private string name;
-    /// <summary>
-    /// Gets the name of the plugin.
-    /// </summary>
-    public string Name {
-      get { return name; }
-      internal set { name = value; }
-    }
-
-    private string description;
-    /// <summary>
-    /// Gets or sets the description of the plugin.
-    /// </summary>
-    public string Description {
-      get { return description; }
-      internal set { description = value; }
-    }
-    private Version version;
-    /// <summary>
-    /// Gets the version of the plugin.
-    /// </summary>
-    public Version Version {
-      get { return version; }
-      internal set { version = value; }
-    }
-
-    private string contactName;
-    /// <summary>
-    /// Gets or sets the name of the contact person for this plugin.
-    /// </summary>
-    public string ContactName {
-      get { return contactName; }
-      internal set { contactName = value; }
-    }
-
-    private string contactEmail;
-    /// <summary>
-    /// Gets or sets the e-mail address of the contact person for this plugin.
-    /// </summary>
-    public string ContactEmail {
-      get { return contactEmail; }
-      internal set { contactEmail = value; }
-    }
-    private string licenseText;
-    /// <summary>
-    /// Gets or sets the license text of the plugin.
-    /// </summary>
-    public string LicenseText {
-      get { return licenseText; }
-      internal set { licenseText = value; }
-    }
-
-    private PluginState pluginState;
-    /// <summary>
-    /// Gets or sets the plugin state.
-    /// </summary>
-    public PluginState PluginState {
-      get { return pluginState; }
-    }
-
-    private string loadingErrorInformation;
-    /// <summary>
-    /// Gets the error message why this plugin has been disabled.
-    /// </summary>
-    public string LoadingErrorInformation {
-      get {
-        return loadingErrorInformation;
-      }
-    }
-
-    private List<PluginFile> files = new List<PluginFile>();
-    /// <summary>
-    /// Gets the names of all files that belong to this plugin.
-    /// These files are deleted when the plugin is removed or updated.
-    /// </summary>
-    public IEnumerable<IPluginFile> Files {
-      get { return files.Cast<IPluginFile>(); }
-    }
-
-    internal void AddFiles(IEnumerable<PluginFile> fileNames) {
-      files.AddRange(fileNames);
-    }
-
-    private List<PluginDescription> dependencies = new List<PluginDescription>();
-    internal IEnumerable<PluginDescription> Dependencies {
-      get { return dependencies; }
-    }
-    /// <summary>
-    /// Gets all dependencies of the plugin.
-    /// </summary>
-    IEnumerable<IPluginDescription> IPluginDescription.Dependencies {
-      get { return dependencies.Cast<IPluginDescription>(); }
-    }
-
-    internal void AddDependency(PluginDescription dependency) {
-      dependencies.Add(dependency);
-    }
-
-
-    /// <summary>
-    /// Gets the locations (file names) of the assemblies that belong to this plugin.
-    /// </summary>
-    public IEnumerable<string> AssemblyLocations {
-      get { return Files.Where(f => f.Type == PluginFileType.Assembly).Select(f => f.Name); }
-    }
-
-    /// <summary>
-    /// Gets and sets the list of assembly names for this plugin. Assembly names are only available after the plugin has been loaded.
-    /// </summary>
-    private List<string> assemblyNames;
-    public IEnumerable<string> AssemblyNames {
-      get { return assemblyNames; }
-      set { this.assemblyNames = new List<string>(value); }
-    }
-
-    internal PluginDescription() {
-      pluginState = PluginState.Undefined;
-    }
-
-    internal void Disable(string loadingErrorInformation) {
-      if (pluginState != PluginState.Undefined)
-        throw new InvalidOperationException("Cannot disable a plugin in state " + pluginState);
-      pluginState = PluginState.Disabled;
-      this.loadingErrorInformation = loadingErrorInformation;
-    }
-
-    internal void Enable() {
-      if (pluginState != PluginState.Undefined)
-        throw new InvalidOperationException("Cannot enable a plugin in state " + pluginState);
-      pluginState = PluginState.Enabled;
-    }
-
-    internal void Load() {
-      if (!(pluginState == PluginState.Enabled || pluginState == PluginState.Loaded))
-        throw new InvalidOperationException("Cannot load a plugin in state " + pluginState);
-      pluginState = PluginState.Loaded;
-      nTimesLoaded++;
-    }
-
-    internal void Unload() {
-      if (pluginState != PluginState.Loaded)
-        throw new InvalidOperationException("Cannot unload a plugin in state " + pluginState);
-      nTimesLoaded--;
-      if (nTimesLoaded == 0) pluginState = PluginState.Enabled;
-    }
-
-
-    /// <summary>
-    /// Gets the string representation of the plugin.
-    /// </summary>
-    /// <returns>The name of the plugin.</returns>
-    public override string ToString() {
-      return Name + " " + Version;
-    }
-
-    // equals and hashcode have to be implemented because we want to compare PluginDescriptions from 
-    // different AppDomains and serialization destroys reference equality
-    /// <summary>
-    /// Checks whether the given object is equal to the current plugin.
-    /// </summary>
-    /// <param name="obj">The object to compare.</param>
-    /// <returns><c>true</c> if it is equal, <c>false</c> otherwise.</returns>
-    public override bool Equals(object obj) {
-      PluginDescription other = obj as PluginDescription;
-      if (other == null) return false;
-
-      return other.Name == this.Name && other.Version == this.Version;
-    }
-    /// <summary>
-    /// Gets the hash code of the current plugin.
-    /// </summary>
-    /// <returns>The hash code of the plugin.</returns>
-    public override int GetHashCode() {
-      if (version != null) {
-        return name.GetHashCode() + version.GetHashCode();
-      } else return name.GetHashCode();
-    }
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginFile.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginFile.cs	(revision 13340)
+++ 	(revision )
@@ -1,68 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-
-namespace HeuristicLab.PluginInfrastructure.Manager {
-  /// <summary>
-  /// Plugin files have a name and a type.
-  /// </summary>
-  [Serializable]
-  public sealed class PluginFile : IPluginFile {
-    #region IPluginFile Members
-
-    private string name;
-    /// <summary>
-    /// Gets the name of the file.
-    /// </summary>
-    public string Name {
-      get { return name; }
-    }
-
-    private PluginFileType type;
-    /// <summary>
-    /// Gets the type of the file.
-    /// </summary>
-    public PluginFileType Type {
-      get { return type; }
-    }
-
-    #endregion
-
-    /// <summary>
-    /// Inizialize a new instance of <see cref="PluginFile" />
-    /// </summary>
-    /// <param name="name">File name</param>
-    /// <param name="type">File type</param>
-    public PluginFile(string name, PluginFileType type) {
-      this.name = name;
-      this.type = type;
-    }
-
-    /// <summary>
-    /// ToString override for <see cref="PluginFile" />
-    /// </summary>
-    /// <returns>Plugin file name</returns>
-    public override string ToString() {
-      return name;
-    }
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginInfrastructureEventArgs.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginInfrastructureEventArgs.cs	(revision 13340)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-
-namespace HeuristicLab.PluginInfrastructure.Manager {
-  [Serializable]
-  public sealed class PluginInfrastructureEventArgs : EventArgs {
-    public object Entity { get; private set; }
-    public PluginInfrastructureEventArgs(object entity) {
-      this.Entity = entity;
-    }
-
-    private static PluginInfrastructureEventArgs emptyArgs = new PluginInfrastructureEventArgs(string.Empty);
-    public new static PluginInfrastructureEventArgs Empty {
-      get { return emptyArgs; }
-    }
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginManager.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginManager.cs	(revision 13340)
+++ 	(revision )
@@ -1,212 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Security.Permissions;
-
-namespace HeuristicLab.PluginInfrastructure.Manager {
-
-  // must extend MarshalByRefObject because of event passing between Loader and PluginManager (each in it's own AppDomain)
-  /// <summary>
-  /// Class to manage different plugins.
-  /// </summary>
-  public sealed class PluginManager : MarshalByRefObject {
-    public event EventHandler<PluginInfrastructureEventArgs> PluginLoaded;
-    public event EventHandler<PluginInfrastructureEventArgs> PluginUnloaded;
-    public event EventHandler<PluginInfrastructureEventArgs> Initializing;
-    public event EventHandler<PluginInfrastructureEventArgs> Initialized;
-    public event EventHandler<PluginInfrastructureEventArgs> ApplicationStarting;
-    public event EventHandler<PluginInfrastructureEventArgs> ApplicationStarted;
-
-    private string pluginDir;
-
-    private List<PluginDescription> plugins;
-    /// <summary>
-    /// Gets all installed plugins.
-    /// </summary>
-    public IEnumerable<PluginDescription> Plugins {
-      get { return plugins; }
-    }
-
-    private List<ApplicationDescription> applications;
-    /// <summary>
-    /// Gets all installed applications.
-    /// </summary>
-    public IEnumerable<ApplicationDescription> Applications {
-      get { return applications; }
-    }
-
-    private object locker = new object();
-    private bool initialized;
-
-    public PluginManager(string pluginDir) {
-      this.pluginDir = pluginDir;
-      plugins = new List<PluginDescription>();
-      applications = new List<ApplicationDescription>();
-      initialized = false;
-    }
-
-    /// <summary>
-    /// Determines installed plugins and checks if all plugins are loadable.
-    /// </summary>
-    public void DiscoverAndCheckPlugins() {
-      OnInitializing(PluginInfrastructureEventArgs.Empty);
-      AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
-      setup.ApplicationBase = pluginDir;
-      AppDomain pluginDomain = null;
-      try {
-        pluginDomain = AppDomain.CreateDomain("plugin domain", null, setup);
-        Type pluginValidatorType = typeof(PluginValidator);
-        PluginValidator remoteValidator = (PluginValidator)pluginDomain.CreateInstanceAndUnwrap(pluginValidatorType.Assembly.FullName, pluginValidatorType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null);
-        remoteValidator.PluginDir = pluginDir;
-        // forward all events from the remoteValidator to listeners
-        remoteValidator.PluginLoaded +=
-          delegate(object sender, PluginInfrastructureEventArgs e) {
-            OnPluginLoaded(e);
-          };
-        // get list of plugins and applications from the validator
-        plugins.Clear(); applications.Clear();
-        plugins.AddRange(remoteValidator.Plugins);
-        applications.AddRange(remoteValidator.Applications);
-      }
-      finally {
-        // discard the AppDomain that was used for plugin discovery
-        AppDomain.Unload(pluginDomain);
-        // unload all plugins
-        foreach (var pluginDescription in plugins.Where(x => x.PluginState == PluginState.Loaded)) {
-          pluginDescription.Unload();
-          OnPluginUnloaded(new PluginInfrastructureEventArgs(pluginDescription));
-        }
-        initialized = true;
-        OnInitialized(PluginInfrastructureEventArgs.Empty);
-      }
-    }
-
-
-    /// <summary>
-    /// Starts an application in a separate AppDomain.
-    /// Loads all enabled plugins and starts the application via an ApplicationManager instance activated in the new AppDomain.
-    /// </summary>
-    /// <param name="appInfo">application to run</param>
-    public void Run(ApplicationDescription appInfo, ICommandLineArgument[] args) {
-      if (!initialized) throw new InvalidOperationException("PluginManager is not initialized. DiscoverAndCheckPlugins() must be called before Run()");
-      // create a separate AppDomain for the application
-      // initialize the static ApplicationManager in the AppDomain
-      // and remotely tell it to start the application
-
-      OnApplicationStarting(new PluginInfrastructureEventArgs(appInfo));
-      AppDomain applicationDomain = null;
-      try {
-        AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
-        setup.PrivateBinPath = pluginDir;
-        applicationDomain = AppDomain.CreateDomain(AppDomain.CurrentDomain.FriendlyName, null, setup);
-        Type applicationManagerType = typeof(DefaultApplicationManager);
-        DefaultApplicationManager applicationManager =
-          (DefaultApplicationManager)applicationDomain.CreateInstanceAndUnwrap(applicationManagerType.Assembly.FullName, applicationManagerType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null);
-        applicationManager.PluginLoaded += applicationManager_PluginLoaded;
-        applicationManager.PluginUnloaded += applicationManager_PluginUnloaded;
-        applicationManager.PrepareApplicationDomain(applications, plugins);
-        OnApplicationStarted(new PluginInfrastructureEventArgs(appInfo));
-        applicationManager.Run(appInfo, args);
-      }
-      finally {
-        // make sure domain is unloaded in all cases
-        AppDomain.Unload(applicationDomain);
-      }
-    }
-
-    private void applicationManager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) {
-      // unload the matching plugin description (
-      PluginDescription desc = (PluginDescription)e.Entity;
-
-      // access to plugin descriptions has to be synchronized because multiple applications 
-      // can be started or stopped at the same time
-      lock (locker) {
-        // also unload the matching plugin description in this AppDomain
-        plugins.First(x => x.Equals(desc)).Unload();
-      }
-      OnPluginUnloaded(e);
-    }
-
-    private void applicationManager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) {
-      // load the matching plugin description (
-      PluginDescription desc = (PluginDescription)e.Entity;
-      // access to plugin descriptions has to be synchronized because multiple applications 
-      // can be started or stopped at the same time
-      lock (locker) {
-        // also load the matching plugin description in this AppDomain
-        plugins.First(x => x.Equals(desc)).Load();
-      }
-      OnPluginLoaded(e);
-    }
-
-    #region event raising methods
-    private void OnPluginLoaded(PluginInfrastructureEventArgs e) {
-      if (PluginLoaded != null) {
-        PluginLoaded(this, e);
-      }
-    }
-
-    private void OnPluginUnloaded(PluginInfrastructureEventArgs e) {
-      if (PluginUnloaded != null) {
-        PluginUnloaded(this, e);
-      }
-    }
-
-    private void OnInitializing(PluginInfrastructureEventArgs e) {
-      if (Initializing != null) {
-        Initializing(this, e);
-      }
-    }
-
-    private void OnInitialized(PluginInfrastructureEventArgs e) {
-      if (Initialized != null) {
-        Initialized(this, e);
-      }
-    }
-
-    private void OnApplicationStarting(PluginInfrastructureEventArgs e) {
-      if (ApplicationStarting != null) {
-        ApplicationStarting(this, e);
-      }
-    }
-
-    private void OnApplicationStarted(PluginInfrastructureEventArgs e) {
-      if (ApplicationStarted != null) {
-        ApplicationStarted(this, e);
-      }
-    }
-    #endregion
-
-    // infinite lease time
-    /// <summary>
-    /// Make sure that the plugin manager is never disposed (necessary for cross-app-domain events)
-    /// </summary>
-    /// <returns><c>null</c>.</returns>
-    [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
-    public override object InitializeLifetimeService() {
-      return null;
-    }
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Manager/PluginValidator.cs	(revision 13340)
+++ 	(revision )
@@ -1,634 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Reflection;
-using System.Security;
-using System.Text;
-
-
-namespace HeuristicLab.PluginInfrastructure.Manager {
-  /// <summary>
-  /// Discovers all installed plugins in the plugin directory. Checks correctness of plugin meta-data and if
-  /// all plugin files are available and checks plugin dependencies. 
-  /// </summary>
-  internal sealed class PluginValidator : MarshalByRefObject {
-    // private class to store plugin dependency declarations while reflecting over plugins
-    private class PluginDependency {
-      public string Name { get; private set; }
-      public Version Version { get; private set; }
-
-      public PluginDependency(string name, Version version) {
-        this.Name = name;
-        this.Version = version;
-      }
-    }
-
-
-    internal event EventHandler<PluginInfrastructureEventArgs> PluginLoaded;
-
-    private Dictionary<PluginDescription, IEnumerable<PluginDependency>> pluginDependencies;
-
-    private List<ApplicationDescription> applications;
-    internal IEnumerable<ApplicationDescription> Applications {
-      get {
-        if (string.IsNullOrEmpty(PluginDir)) throw new InvalidOperationException("PluginDir is not set.");
-        if (applications == null) DiscoverAndCheckPlugins();
-        return applications;
-      }
-    }
-
-    private IEnumerable<PluginDescription> plugins;
-    internal IEnumerable<PluginDescription> Plugins {
-      get {
-        if (string.IsNullOrEmpty(PluginDir)) throw new InvalidOperationException("PluginDir is not set.");
-        if (plugins == null) DiscoverAndCheckPlugins();
-        return plugins;
-      }
-    }
-
-    internal string PluginDir { get; set; }
-
-    internal PluginValidator() {
-      this.pluginDependencies = new Dictionary<PluginDescription, IEnumerable<PluginDependency>>();
-
-      // ReflectionOnlyAssemblyResolveEvent must be handled because we load assemblies from the plugin path 
-      // (which is not listed in the default assembly lookup locations)
-      AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += ReflectionOnlyAssemblyResolveEventHandler;
-    }
-
-    private Dictionary<string, Assembly> reflectionOnlyAssemblies = new Dictionary<string, Assembly>();
-    private Assembly ReflectionOnlyAssemblyResolveEventHandler(object sender, ResolveEventArgs args) {
-      if (reflectionOnlyAssemblies.ContainsKey(args.Name))
-        return reflectionOnlyAssemblies[args.Name];
-      else
-        return Assembly.ReflectionOnlyLoad(args.Name);
-    }
-
-
-    /// <summary>
-    /// Init first clears all internal datastructures (including plugin lists)
-    /// 1. All assemblies in the plugins directory are loaded into the reflection only context.
-    /// 2. The validator checks if all necessary files for each plugin are available.
-    /// 3. The validator checks if all declared plugin assemblies can be loaded.
-    /// 4. The validator builds the tree of plugin descriptions (dependencies)
-    /// 5. The validator checks if there are any cycles in the plugin dependency graph and disables plugin with circular dependencies
-    /// 6. The validator checks for each plugin if any dependency is disabled.
-    /// 7. All plugins that are not disabled are loaded into the execution context.
-    /// 8. Each loaded plugin (all assemblies) is searched for a types that implement IPlugin
-    ///    then one instance of each IPlugin type is activated and the OnLoad hook is called.
-    /// 9. All types implementing IApplication are discovered
-    /// </summary>
-    internal void DiscoverAndCheckPlugins() {
-      pluginDependencies.Clear();
-
-      IEnumerable<Assembly> reflectionOnlyAssemblies = ReflectionOnlyLoadDlls(PluginDir);
-      IEnumerable<PluginDescription> pluginDescriptions = GatherPluginDescriptions(reflectionOnlyAssemblies);
-      CheckPluginFiles(pluginDescriptions);
-
-      // check if all plugin assemblies can be loaded
-      CheckPluginAssemblies(pluginDescriptions);
-
-      // a full list of plugin descriptions is available now we can build the dependency tree
-      BuildDependencyTree(pluginDescriptions);
-
-      // check for dependency cycles
-      CheckPluginDependencyCycles(pluginDescriptions);
-
-      // 1st time recursively check if all necessary plugins are available and not disabled
-      // disable plugins with missing or disabled dependencies 
-      // to prevent that plugins with missing dependencies are loaded into the execution context
-      // in the next step
-      CheckPluginDependencies(pluginDescriptions);
-
-      // test full loading (in contrast to reflection only loading) of plugins
-      // disables plugins that are not loaded correctly
-      CheckExecutionContextLoad(pluginDescriptions);
-
-      // 2nd time recursively check if all necessary plugins have been loaded successfully and not disabled
-      // disable plugins with for which dependencies could not be loaded successfully
-      CheckPluginDependencies(pluginDescriptions);
-
-      // mark all plugins as enabled that were not disabled in CheckPluginFiles, CheckPluginAssemblies, 
-      // CheckCircularDependencies, CheckPluginDependencies and CheckExecutionContextLoad
-      foreach (var desc in pluginDescriptions)
-        if (desc.PluginState != PluginState.Disabled)
-          desc.Enable();
-
-      // load the enabled plugins
-      LoadPlugins(pluginDescriptions);
-
-      plugins = pluginDescriptions;
-      DiscoverApplications(pluginDescriptions);
-    }
-
-    private void DiscoverApplications(IEnumerable<PluginDescription> pluginDescriptions) {
-      applications = new List<ApplicationDescription>();
-      foreach (IApplication application in GetApplications(pluginDescriptions)) {
-        Type appType = application.GetType();
-        ApplicationAttribute attr = (from x in appType.GetCustomAttributes(typeof(ApplicationAttribute), false)
-                                     select (ApplicationAttribute)x).Single();
-        ApplicationDescription info = new ApplicationDescription();
-        PluginDescription declaringPlugin = GetDeclaringPlugin(appType, pluginDescriptions);
-        info.Name = application.Name;
-        info.Version = declaringPlugin.Version;
-        info.Description = application.Description;
-        info.AutoRestart = attr.RestartOnErrors;
-        info.DeclaringAssemblyName = appType.Assembly.GetName().Name;
-        info.DeclaringTypeName = appType.Namespace + "." + application.GetType().Name;
-
-        applications.Add(info);
-      }
-    }
-
-    private static IEnumerable<IApplication> GetApplications(IEnumerable<PluginDescription> pluginDescriptions) {
-      return from asm in AppDomain.CurrentDomain.GetAssemblies()
-             from t in asm.GetTypes()
-             where typeof(IApplication).IsAssignableFrom(t) &&
-               !t.IsAbstract && !t.IsInterface && !t.HasElementType
-             where GetDeclaringPlugin(t, pluginDescriptions).PluginState != PluginState.Disabled
-             select (IApplication)Activator.CreateInstance(t);
-    }
-
-    private IEnumerable<Assembly> ReflectionOnlyLoadDlls(string baseDir) {
-      List<Assembly> assemblies = new List<Assembly>();
-      // recursively load .dll files in subdirectories
-      foreach (string dirName in Directory.GetDirectories(baseDir)) {
-        assemblies.AddRange(ReflectionOnlyLoadDlls(dirName));
-      }
-      // try to load each .dll file in the plugin directory into the reflection only context
-      foreach (string filename in Directory.GetFiles(baseDir, "*.dll").Union(Directory.GetFiles(baseDir, "*.exe"))) {
-        try {
-          Assembly asm = Assembly.ReflectionOnlyLoadFrom(filename);
-          RegisterLoadedAssembly(asm);
-          assemblies.Add(asm);
-        }
-        catch (BadImageFormatException) { } // just ignore the case that the .dll file is not a CLR assembly (e.g. a native dll)
-        catch (FileLoadException) { }
-        catch (SecurityException) { }
-        catch (ReflectionTypeLoadException) { } // referenced assemblies are missing
-      }
-      return assemblies;
-    }
-
-    /// <summary>
-    /// Checks if all plugin assemblies can be loaded. If an assembly can't be loaded the plugin is disabled.
-    /// </summary>
-    /// <param name="pluginDescriptions"></param>
-    private void CheckPluginAssemblies(IEnumerable<PluginDescription> pluginDescriptions) {
-      foreach (var desc in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) {
-        try {
-          var missingAssemblies = new List<string>();
-          foreach (var asmLocation in desc.AssemblyLocations) {
-            // the assembly must have been loaded in ReflectionOnlyDlls
-            // so we simply determine the name of the assembly and try to find it in the cache of loaded assemblies
-            var asmName = AssemblyName.GetAssemblyName(asmLocation);
-            if (!reflectionOnlyAssemblies.ContainsKey(asmName.FullName)) {
-              missingAssemblies.Add(asmName.FullName);
-            }
-          }
-          if (missingAssemblies.Count > 0) {
-            StringBuilder errorStrBuiler = new StringBuilder();
-            errorStrBuiler.AppendLine("Missing assemblies:");
-            foreach (string missingAsm in missingAssemblies) {
-              errorStrBuiler.AppendLine(missingAsm);
-            }
-            desc.Disable(errorStrBuiler.ToString());
-          }
-        }
-        catch (BadImageFormatException ex) {
-          // disable the plugin
-          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "BadImageFormatException: " + ex.Message);
-        }
-        catch (FileNotFoundException ex) {
-          // disable the plugin
-          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "FileNotFoundException: " + ex.Message);
-        }
-        catch (FileLoadException ex) {
-          // disable the plugin
-          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "FileLoadException: " + ex.Message);
-        }
-        catch (ArgumentException ex) {
-          // disable the plugin
-          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "ArgumentException: " + ex.Message);
-        }
-        catch (SecurityException ex) {
-          // disable the plugin
-          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "SecurityException: " + ex.Message);
-        }
-      }
-    }
-
-
-    // find all types implementing IPlugin in the reflectionOnlyAssemblies and create a list of plugin descriptions
-    // the dependencies in the plugin descriptions are not yet set correctly because we need to create
-    // the full list of all plugin descriptions first
-    private IEnumerable<PluginDescription> GatherPluginDescriptions(IEnumerable<Assembly> assemblies) {
-      List<PluginDescription> pluginDescriptions = new List<PluginDescription>();
-      foreach (Assembly assembly in assemblies) {
-        // GetExportedTypes throws FileNotFoundException when a referenced assembly
-        // of the current assembly is missing.
-        try {
-          // if there is a type that implements IPlugin
-          // use AssemblyQualifiedName to compare the types because we can't directly 
-          // compare ReflectionOnly types and execution types
-          var assemblyPluginDescriptions = from t in assembly.GetExportedTypes()
-                                           where !t.IsAbstract && t.GetInterfaces().Any(x => x.AssemblyQualifiedName == typeof(IPlugin).AssemblyQualifiedName)
-                                           select GetPluginDescription(t);
-          pluginDescriptions.AddRange(assemblyPluginDescriptions);
-        }
-        // ignore exceptions. Just don't yield a plugin description when an exception is thrown
-        catch (FileNotFoundException) {
-        }
-        catch (FileLoadException) {
-        }
-        catch (InvalidPluginException) {
-        }
-        catch (TypeLoadException) {
-        }
-        catch (MissingMemberException) {
-        }
-      }
-      return pluginDescriptions;
-    }
-
-    /// <summary>
-    /// Extracts plugin information for this type.
-    /// Reads plugin name, list and type of files and dependencies of the plugin. This information is necessary for
-    /// plugin dependency checking before plugin activation.
-    /// </summary>
-    /// <param name="pluginType"></param>
-    private PluginDescription GetPluginDescription(Type pluginType) {
-
-      string pluginName, pluginDescription, pluginVersion;
-      string contactName, contactAddress;
-      GetPluginMetaData(pluginType, out pluginName, out pluginDescription, out pluginVersion);
-      GetPluginContactMetaData(pluginType, out contactName, out contactAddress);
-      var pluginFiles = GetPluginFilesMetaData(pluginType);
-      var pluginDependencies = GetPluginDependencyMetaData(pluginType);
-
-      // minimal sanity check of the attribute values
-      if (!string.IsNullOrEmpty(pluginName) &&
-          pluginFiles.Count() > 0 &&                                 // at least one file
-          pluginFiles.Any(f => f.Type == PluginFileType.Assembly)) { // at least one assembly
-        // create a temporary PluginDescription that contains the attribute values
-        PluginDescription info = new PluginDescription();
-        info.Name = pluginName;
-        info.Description = pluginDescription;
-        info.Version = new Version(pluginVersion);
-        info.ContactName = contactName;
-        info.ContactEmail = contactAddress;
-        info.LicenseText = ReadLicenseFiles(pluginFiles);
-        info.AddFiles(pluginFiles);
-
-        this.pluginDependencies[info] = pluginDependencies;
-        return info;
-      } else {
-        throw new InvalidPluginException("Invalid metadata in plugin " + pluginType.ToString());
-      }
-    }
-
-    private static string ReadLicenseFiles(IEnumerable<PluginFile> pluginFiles) {
-      // combine the contents of all plugin files 
-      var licenseFiles = from file in pluginFiles
-                         where file.Type == PluginFileType.License
-                         select file;
-      if (licenseFiles.Count() == 0) return string.Empty;
-      StringBuilder licenseTextBuilder = new StringBuilder();
-      licenseTextBuilder.AppendLine(File.ReadAllText(licenseFiles.First().Name));
-      foreach (var licenseFile in licenseFiles.Skip(1)) {
-        licenseTextBuilder.AppendLine().AppendLine(); // leave some empty space between multiple license files
-        licenseTextBuilder.AppendLine(File.ReadAllText(licenseFile.Name));
-      }
-      return licenseTextBuilder.ToString();
-    }
-
-    private static IEnumerable<PluginDependency> GetPluginDependencyMetaData(Type pluginType) {
-      // get all attributes of type PluginDependency
-      var dependencyAttributes = from attr in CustomAttributeData.GetCustomAttributes(pluginType)
-                                 where IsAttributeDataForType(attr, typeof(PluginDependencyAttribute))
-                                 select attr;
-
-      foreach (var dependencyAttr in dependencyAttributes) {
-        string name = (string)dependencyAttr.ConstructorArguments[0].Value;
-        Version version = new Version("0.0.0.0"); // default version
-        // check if version is given for now
-        // later when the constructor of PluginDependencyAttribute with only one argument has been removed
-        // this conditional can be removed as well
-        if (dependencyAttr.ConstructorArguments.Count > 1) {
-          try {
-            version = new Version((string)dependencyAttr.ConstructorArguments[1].Value); // might throw FormatException
-          }
-          catch (FormatException ex) {
-            throw new InvalidPluginException("Invalid version format of dependency " + name + " in plugin " + pluginType.ToString(), ex);
-          }
-        }
-        yield return new PluginDependency(name, version);
-      }
-    }
-
-    private static void GetPluginContactMetaData(Type pluginType, out string contactName, out string contactAddress) {
-      // get attribute of type ContactInformation if there is any
-      var contactInfoAttribute = (from attr in CustomAttributeData.GetCustomAttributes(pluginType)
-                                  where IsAttributeDataForType(attr, typeof(ContactInformationAttribute))
-                                  select attr).SingleOrDefault();
-
-      if (contactInfoAttribute != null) {
-        contactName = (string)contactInfoAttribute.ConstructorArguments[0].Value;
-        contactAddress = (string)contactInfoAttribute.ConstructorArguments[1].Value;
-      } else {
-        contactName = string.Empty;
-        contactAddress = string.Empty;
-      }
-    }
-
-    // not static because we need the PluginDir property
-    private IEnumerable<PluginFile> GetPluginFilesMetaData(Type pluginType) {
-      // get all attributes of type PluginFileAttribute
-      var pluginFileAttributes = from attr in CustomAttributeData.GetCustomAttributes(pluginType)
-                                 where IsAttributeDataForType(attr, typeof(PluginFileAttribute))
-                                 select attr;
-      foreach (var pluginFileAttribute in pluginFileAttributes) {
-        string pluginFileName = (string)pluginFileAttribute.ConstructorArguments[0].Value;
-        PluginFileType fileType = (PluginFileType)pluginFileAttribute.ConstructorArguments[1].Value;
-        yield return new PluginFile(Path.GetFullPath(Path.Combine(PluginDir, pluginFileName)), fileType);
-      }
-    }
-
-    private static void GetPluginMetaData(Type pluginType, out string pluginName, out string pluginDescription, out string pluginVersion) {
-      // there must be a single attribute of type PluginAttribute
-      var pluginMetaDataAttr = (from attr in CustomAttributeData.GetCustomAttributes(pluginType)
-                                where IsAttributeDataForType(attr, typeof(PluginAttribute))
-                                select attr).Single();
-
-      pluginName = (string)pluginMetaDataAttr.ConstructorArguments[0].Value;
-
-      // default description and version
-      pluginVersion = "0.0.0.0";
-      pluginDescription = string.Empty;
-      if (pluginMetaDataAttr.ConstructorArguments.Count() == 2) {
-        // if two arguments are given the second argument is the version
-        pluginVersion = (string)pluginMetaDataAttr.ConstructorArguments[1].Value;
-      } else if (pluginMetaDataAttr.ConstructorArguments.Count() == 3) {
-        // if three arguments are given the second argument is the description and the third is the version
-        pluginDescription = (string)pluginMetaDataAttr.ConstructorArguments[1].Value;
-        pluginVersion = (string)pluginMetaDataAttr.ConstructorArguments[2].Value;
-      }
-    }
-
-    private static bool IsAttributeDataForType(CustomAttributeData attributeData, Type attributeType) {
-      return attributeData.Constructor.DeclaringType.AssemblyQualifiedName == attributeType.AssemblyQualifiedName;
-    }
-
-    // builds a dependency tree of all plugin descriptions
-    // searches matching plugin descriptions based on the list of dependency names for each plugin
-    // and sets the dependencies in the plugin descriptions
-    private void BuildDependencyTree(IEnumerable<PluginDescription> pluginDescriptions) {
-      foreach (var desc in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) {
-        var missingDependencies = new List<PluginDependency>();
-        foreach (var dependency in pluginDependencies[desc]) {
-          var matchingDescriptions = from availablePlugin in pluginDescriptions
-                                     where availablePlugin.PluginState != PluginState.Disabled
-                                     where availablePlugin.Name == dependency.Name
-                                     where IsCompatiblePluginVersion(availablePlugin.Version, dependency.Version)
-                                     select availablePlugin;
-          if (matchingDescriptions.Count() > 0) {
-            desc.AddDependency(matchingDescriptions.Single());
-          } else {
-            missingDependencies.Add(dependency);
-          }
-        }
-        // no plugin description that matches the dependencies are available => plugin is disabled
-        if (missingDependencies.Count > 0) {
-          StringBuilder errorStrBuilder = new StringBuilder();
-          errorStrBuilder.AppendLine("Missing dependencies:");
-          foreach (var missingDep in missingDependencies) {
-            errorStrBuilder.AppendLine(missingDep.Name + " " + missingDep.Version);
-          }
-          desc.Disable(errorStrBuilder.ToString());
-        }
-      }
-    }
-
-    /// <summary>
-    /// Checks if version <paramref name="available"/> is compatible to version <paramref name="requested"/>.
-    /// Note: the compatibility relation is not bijective.
-    /// Compatibility rules:
-    ///  * major and minor number must be the same
-    ///  * build and revision number of <paramref name="available"/> must be larger or equal to <paramref name="requested"/>.
-    /// </summary>
-    /// <param name="available">The available version which should be compared to <paramref name="requested"/>.</param>
-    /// <param name="requested">The requested version that must be matched.</param>
-    /// <returns></returns>
-    private static bool IsCompatiblePluginVersion(Version available, Version requested) {
-      // this condition must be removed after all plugins have been updated to declare plugin and dependency versions
-      if (
-        (requested.Major == 0 && requested.Minor == 0) ||
-        (available.Major == 0 && available.Minor == 0)) return true;
-      return
-        available.Major == requested.Major &&
-        available.Minor == requested.Minor &&
-        available.Build >= requested.Build &&
-        available.Revision >= requested.Revision;
-    }
-
-    private void CheckPluginDependencyCycles(IEnumerable<PluginDescription> pluginDescriptions) {
-      foreach (var plugin in pluginDescriptions) {
-        // if the plugin is not disabled check if there are cycles
-        if (plugin.PluginState != PluginState.Disabled && HasCycleInDependencies(plugin, plugin.Dependencies)) {
-          plugin.Disable("Dependency graph has a cycle.");
-        }
-      }
-    }
-
-    private bool HasCycleInDependencies(PluginDescription plugin, IEnumerable<PluginDescription> pluginDependencies) {
-      foreach (var dep in pluginDependencies) {
-        // if one of the dependencies is the original plugin we found a cycle and can return
-        // if the dependency is already disabled we can ignore the cycle detection because we will disable the plugin anyway
-        // if following one of the dependencies recursively leads to a cycle then we also return
-        if (dep == plugin || dep.PluginState == PluginState.Disabled || HasCycleInDependencies(plugin, dep.Dependencies)) return true;
-      }
-      // no cycle found and none of the direct and indirect dependencies is disabled
-      return false;
-    }
-
-    private void CheckPluginDependencies(IEnumerable<PluginDescription> pluginDescriptions) {
-      foreach (PluginDescription pluginDescription in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) {
-        List<PluginDescription> disabledPlugins = new List<PluginDescription>();
-        if (IsAnyDependencyDisabled(pluginDescription, disabledPlugins)) {
-          StringBuilder errorStrBuilder = new StringBuilder();
-          errorStrBuilder.AppendLine("Dependencies are disabled:");
-          foreach (var disabledPlugin in disabledPlugins) {
-            errorStrBuilder.AppendLine(disabledPlugin.Name + " " + disabledPlugin.Version);
-          }
-          pluginDescription.Disable(errorStrBuilder.ToString());
-        }
-      }
-    }
-
-
-    private bool IsAnyDependencyDisabled(PluginDescription descr, List<PluginDescription> disabledPlugins) {
-      if (descr.PluginState == PluginState.Disabled) {
-        disabledPlugins.Add(descr);
-        return true;
-      }
-      foreach (PluginDescription dependency in descr.Dependencies) {
-        IsAnyDependencyDisabled(dependency, disabledPlugins);
-      }
-      return disabledPlugins.Count > 0;
-    }
-
-    // tries to load all plugin assemblies into the execution context
-    // if an assembly of a plugin cannot be loaded the plugin is disabled
-    private void CheckExecutionContextLoad(IEnumerable<PluginDescription> pluginDescriptions) {
-      // load all loadable plugins (all dependencies available) into the execution context
-      foreach (var desc in PluginDescriptionIterator.IterateDependenciesBottomUp(pluginDescriptions
-                                                                                .Where(x => x.PluginState != PluginState.Disabled))) {
-        // store the assembly names so that we can later retrieve the assemblies loaded in the appdomain by name
-        var assemblyNames = new List<string>();
-        foreach (string assemblyLocation in desc.AssemblyLocations) {
-          if (desc.PluginState != PluginState.Disabled) {
-            try {
-              string assemblyName = (from assembly in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()
-                                     where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)
-                                     select assembly.FullName).Single();
-              // now load the assemblies into the execution context  
-              // this can still lead to an exception
-              // even when the assemby was successfully loaded into the reflection only context before 
-              // when loading the assembly using it's assemblyName it can be loaded from a different location than before (e.g. the GAC)
-              Assembly.Load(assemblyName);
-              assemblyNames.Add(assemblyName);
-            }
-            catch (BadImageFormatException) {
-              desc.Disable(Path.GetFileName(assemblyLocation) + " is not a valid assembly.");
-            }
-            catch (FileLoadException) {
-              desc.Disable("Can't load file " + Path.GetFileName(assemblyLocation));
-            }
-            catch (FileNotFoundException) {
-              desc.Disable("File " + Path.GetFileName(assemblyLocation) + " is missing.");
-            }
-            catch (SecurityException) {
-              desc.Disable("File " + Path.GetFileName(assemblyLocation) + " can't be loaded because of security constraints.");
-            }
-            catch (NotSupportedException ex) {
-              // disable the plugin
-              desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "NotSupportedException: " + ex.Message);
-            }
-          }
-        }
-        desc.AssemblyNames = assemblyNames;
-      }
-    }
-
-    // assumes that all plugin assemblies have been loaded into the execution context via CheckExecutionContextLoad
-    // for each enabled plugin:
-    // calls OnLoad method of the plugin 
-    // and raises the PluginLoaded event
-    private void LoadPlugins(IEnumerable<PluginDescription> pluginDescriptions) {
-      List<Assembly> assemblies = new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
-      foreach (var desc in pluginDescriptions) {
-        if (desc.PluginState == PluginState.Enabled) {
-          // cannot use ApplicationManager to retrieve types because it is not yet instantiated
-          foreach (string assemblyName in desc.AssemblyNames) {
-            var asm = (from assembly in assemblies
-                       where assembly.FullName == assemblyName
-                       select assembly)
-                      .SingleOrDefault();
-            if (asm == null) throw new InvalidPluginException("Could not load assembly " + assemblyName + " for plugin " + desc.Name);
-            foreach (Type pluginType in asm.GetTypes()) {
-              if (typeof(IPlugin).IsAssignableFrom(pluginType) && !pluginType.IsAbstract && !pluginType.IsInterface && !pluginType.HasElementType) {
-                IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType);
-                plugin.OnLoad();
-                OnPluginLoaded(new PluginInfrastructureEventArgs(desc));
-              }
-            }
-          } // end foreach assembly in plugin
-          desc.Load();
-        }
-      } // end foreach plugin description
-    }
-
-    // checks if all declared plugin files are actually available and disables plugins with missing files
-    private void CheckPluginFiles(IEnumerable<PluginDescription> pluginDescriptions) {
-      foreach (PluginDescription desc in pluginDescriptions) {
-        IEnumerable<string> missingFiles;
-        if (ArePluginFilesMissing(desc, out missingFiles)) {
-          StringBuilder errorStrBuilder = new StringBuilder();
-          errorStrBuilder.AppendLine("Missing files:");
-          foreach (string fileName in missingFiles) {
-            errorStrBuilder.AppendLine(fileName);
-          }
-          desc.Disable(errorStrBuilder.ToString());
-        }
-      }
-    }
-
-    private bool ArePluginFilesMissing(PluginDescription pluginDescription, out IEnumerable<string> missingFiles) {
-      List<string> missing = new List<string>();
-      foreach (string filename in pluginDescription.Files.Select(x => x.Name)) {
-        if (!FileLiesInDirectory(PluginDir, filename) ||
-          !File.Exists(filename)) {
-          missing.Add(filename);
-        }
-      }
-      missingFiles = missing;
-      return missing.Count > 0;
-    }
-
-    private static bool FileLiesInDirectory(string dir, string fileName) {
-      var basePath = Path.GetFullPath(dir);
-      return Path.GetFullPath(fileName).StartsWith(basePath);
-    }
-
-    private static PluginDescription GetDeclaringPlugin(Type appType, IEnumerable<PluginDescription> plugins) {
-      return (from p in plugins
-              from asmLocation in p.AssemblyLocations
-              where Path.GetFullPath(asmLocation).Equals(Path.GetFullPath(appType.Assembly.Location), StringComparison.CurrentCultureIgnoreCase)
-              select p).Single();
-    }
-
-    // register assembly in the assembly cache for the ReflectionOnlyAssemblyResolveEvent
-    private void RegisterLoadedAssembly(Assembly asm) {
-      if (reflectionOnlyAssemblies.ContainsKey(asm.FullName) || reflectionOnlyAssemblies.ContainsKey(asm.GetName().Name)) {
-        throw new ArgumentException("An assembly with the name " + asm.GetName().Name + " has been registered already.", "asm");
-      }
-      reflectionOnlyAssemblies.Add(asm.FullName, asm);
-      reflectionOnlyAssemblies.Add(asm.GetName().Name, asm); // add short name
-    }
-
-    private void OnPluginLoaded(PluginInfrastructureEventArgs e) {
-      if (PluginLoaded != null)
-        PluginLoaded(this, e);
-    }
-
-    /// <summary>
-    /// Initializes the life time service with an infinite lease time.
-    /// </summary>
-    /// <returns><c>null</c>.</returns>
-    public override object InitializeLifetimeService() {
-      return null;
-    }
-  }
-}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginBase.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginBase.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginBase.cs	(revision 13341)
@@ -0,0 +1,61 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+
+namespace HeuristicLab.PluginInfrastructure {
+  /// <summary>
+  /// Abstract base implementation of the IPlugin interface.
+  /// </summary>
+  public abstract class PluginBase : IPlugin {
+    /// <summary>
+    /// Initializes a new instance of <see cref="PluginBase"/>.
+    /// </summary>
+    protected PluginBase() { }
+
+    private PluginAttribute PluginAttribute {
+      get {
+        object[] pluginAttributes = this.GetType().GetCustomAttributes(typeof(PluginAttribute), false);
+        // exactly one attribute of the type PluginDescriptionAttribute must be given
+        if (pluginAttributes.Length == 0) {
+          throw new InvalidPluginException("PluginAttribute on type " + this.GetType() + " is missing.");
+        } else if (pluginAttributes.Length > 1) {
+          throw new InvalidPluginException("Found multiple PluginAttributes on type " + this.GetType());
+        }
+        return (PluginAttribute)pluginAttributes[0];
+      }
+    }
+
+    #region IPlugin Members
+    /// <inheritdoc />
+    public string Name {
+      get {
+        return PluginAttribute.Name;
+      }
+    }
+
+    /// <inhertitdoc />
+    public virtual void OnLoad() { }
+    /// <inhertitdoc />
+    public virtual void OnUnload() { }
+    #endregion
+
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginDescription.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginDescription.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginDescription.cs	(revision 13341)
@@ -0,0 +1,213 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace HeuristicLab.PluginInfrastructure.Manager {
+  /// <summary>
+  /// Holds information of loaded plugins that is needed for plugin management.
+  /// Used to represent plugins in AppDomains without loading the plugin assemblies.
+  /// </summary>
+  [Serializable]
+  public sealed class PluginDescription : IPluginDescription {
+    private int nTimesLoaded;
+
+    private string name;
+    /// <summary>
+    /// Gets the name of the plugin.
+    /// </summary>
+    public string Name {
+      get { return name; }
+      internal set { name = value; }
+    }
+
+    private string description;
+    /// <summary>
+    /// Gets or sets the description of the plugin.
+    /// </summary>
+    public string Description {
+      get { return description; }
+      internal set { description = value; }
+    }
+    private Version version;
+    /// <summary>
+    /// Gets the version of the plugin.
+    /// </summary>
+    public Version Version {
+      get { return version; }
+      internal set { version = value; }
+    }
+
+    private string contactName;
+    /// <summary>
+    /// Gets or sets the name of the contact person for this plugin.
+    /// </summary>
+    public string ContactName {
+      get { return contactName; }
+      internal set { contactName = value; }
+    }
+
+    private string contactEmail;
+    /// <summary>
+    /// Gets or sets the e-mail address of the contact person for this plugin.
+    /// </summary>
+    public string ContactEmail {
+      get { return contactEmail; }
+      internal set { contactEmail = value; }
+    }
+    private string licenseText;
+    /// <summary>
+    /// Gets or sets the license text of the plugin.
+    /// </summary>
+    public string LicenseText {
+      get { return licenseText; }
+      internal set { licenseText = value; }
+    }
+
+    private PluginState pluginState;
+    /// <summary>
+    /// Gets or sets the plugin state.
+    /// </summary>
+    public PluginState PluginState {
+      get { return pluginState; }
+    }
+
+    private string loadingErrorInformation;
+    /// <summary>
+    /// Gets the error message why this plugin has been disabled.
+    /// </summary>
+    public string LoadingErrorInformation {
+      get {
+        return loadingErrorInformation;
+      }
+    }
+
+    private List<PluginFile> files = new List<PluginFile>();
+    /// <summary>
+    /// Gets the names of all files that belong to this plugin.
+    /// These files are deleted when the plugin is removed or updated.
+    /// </summary>
+    public IEnumerable<IPluginFile> Files {
+      get { return files.Cast<IPluginFile>(); }
+    }
+
+    internal void AddFiles(IEnumerable<PluginFile> fileNames) {
+      files.AddRange(fileNames);
+    }
+
+    private List<PluginDescription> dependencies = new List<PluginDescription>();
+    internal IEnumerable<PluginDescription> Dependencies {
+      get { return dependencies; }
+    }
+    /// <summary>
+    /// Gets all dependencies of the plugin.
+    /// </summary>
+    IEnumerable<IPluginDescription> IPluginDescription.Dependencies {
+      get { return dependencies.Cast<IPluginDescription>(); }
+    }
+
+    internal void AddDependency(PluginDescription dependency) {
+      dependencies.Add(dependency);
+    }
+
+
+    /// <summary>
+    /// Gets the locations (file names) of the assemblies that belong to this plugin.
+    /// </summary>
+    public IEnumerable<string> AssemblyLocations {
+      get { return Files.Where(f => f.Type == PluginFileType.Assembly).Select(f => f.Name); }
+    }
+
+    /// <summary>
+    /// Gets and sets the list of assembly names for this plugin. Assembly names are only available after the plugin has been loaded.
+    /// </summary>
+    private List<string> assemblyNames;
+    public IEnumerable<string> AssemblyNames {
+      get { return assemblyNames; }
+      set { this.assemblyNames = new List<string>(value); }
+    }
+
+    internal PluginDescription() {
+      pluginState = PluginState.Undefined;
+    }
+
+    internal void Disable(string loadingErrorInformation) {
+      if (pluginState != PluginState.Undefined)
+        throw new InvalidOperationException("Cannot disable a plugin in state " + pluginState);
+      pluginState = PluginState.Disabled;
+      this.loadingErrorInformation = loadingErrorInformation;
+    }
+
+    internal void Enable() {
+      if (pluginState != PluginState.Undefined)
+        throw new InvalidOperationException("Cannot enable a plugin in state " + pluginState);
+      pluginState = PluginState.Enabled;
+    }
+
+    internal void Load() {
+      if (!(pluginState == PluginState.Enabled || pluginState == PluginState.Loaded))
+        throw new InvalidOperationException("Cannot load a plugin in state " + pluginState);
+      pluginState = PluginState.Loaded;
+      nTimesLoaded++;
+    }
+
+    internal void Unload() {
+      if (pluginState != PluginState.Loaded)
+        throw new InvalidOperationException("Cannot unload a plugin in state " + pluginState);
+      nTimesLoaded--;
+      if (nTimesLoaded == 0) pluginState = PluginState.Enabled;
+    }
+
+
+    /// <summary>
+    /// Gets the string representation of the plugin.
+    /// </summary>
+    /// <returns>The name of the plugin.</returns>
+    public override string ToString() {
+      return Name + " " + Version;
+    }
+
+    // equals and hashcode have to be implemented because we want to compare PluginDescriptions from 
+    // different AppDomains and serialization destroys reference equality
+    /// <summary>
+    /// Checks whether the given object is equal to the current plugin.
+    /// </summary>
+    /// <param name="obj">The object to compare.</param>
+    /// <returns><c>true</c> if it is equal, <c>false</c> otherwise.</returns>
+    public override bool Equals(object obj) {
+      PluginDescription other = obj as PluginDescription;
+      if (other == null) return false;
+
+      return other.Name == this.Name && other.Version == this.Version;
+    }
+    /// <summary>
+    /// Gets the hash code of the current plugin.
+    /// </summary>
+    /// <returns>The hash code of the plugin.</returns>
+    public override int GetHashCode() {
+      if (version != null) {
+        return name.GetHashCode() + version.GetHashCode();
+      } else return name.GetHashCode();
+    }
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginFile.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginFile.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginFile.cs	(revision 13341)
@@ -0,0 +1,68 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+
+namespace HeuristicLab.PluginInfrastructure.Manager {
+  /// <summary>
+  /// Plugin files have a name and a type.
+  /// </summary>
+  [Serializable]
+  public sealed class PluginFile : IPluginFile {
+    #region IPluginFile Members
+
+    private string name;
+    /// <summary>
+    /// Gets the name of the file.
+    /// </summary>
+    public string Name {
+      get { return name; }
+    }
+
+    private PluginFileType type;
+    /// <summary>
+    /// Gets the type of the file.
+    /// </summary>
+    public PluginFileType Type {
+      get { return type; }
+    }
+
+    #endregion
+
+    /// <summary>
+    /// Inizialize a new instance of <see cref="PluginFile" />
+    /// </summary>
+    /// <param name="name">File name</param>
+    /// <param name="type">File type</param>
+    public PluginFile(string name, PluginFileType type) {
+      this.name = name;
+      this.type = type;
+    }
+
+    /// <summary>
+    /// ToString override for <see cref="PluginFile" />
+    /// </summary>
+    /// <returns>Plugin file name</returns>
+    public override string ToString() {
+      return name;
+    }
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginInfrastructureEventArgs.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginInfrastructureEventArgs.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginInfrastructureEventArgs.cs	(revision 13341)
@@ -0,0 +1,37 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+
+namespace HeuristicLab.PluginInfrastructure.Manager {
+  [Serializable]
+  public sealed class PluginInfrastructureEventArgs : EventArgs {
+    public object Entity { get; private set; }
+    public PluginInfrastructureEventArgs(object entity) {
+      this.Entity = entity;
+    }
+
+    private static PluginInfrastructureEventArgs emptyArgs = new PluginInfrastructureEventArgs(string.Empty);
+    public new static PluginInfrastructureEventArgs Empty {
+      get { return emptyArgs; }
+    }
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginManager.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginManager.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginManager.cs	(revision 13341)
@@ -0,0 +1,212 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Security.Permissions;
+
+namespace HeuristicLab.PluginInfrastructure.Manager {
+
+  // must extend MarshalByRefObject because of event passing between Loader and PluginManager (each in it's own AppDomain)
+  /// <summary>
+  /// Class to manage different plugins.
+  /// </summary>
+  public sealed class PluginManager : MarshalByRefObject {
+    public event EventHandler<PluginInfrastructureEventArgs> PluginLoaded;
+    public event EventHandler<PluginInfrastructureEventArgs> PluginUnloaded;
+    public event EventHandler<PluginInfrastructureEventArgs> Initializing;
+    public event EventHandler<PluginInfrastructureEventArgs> Initialized;
+    public event EventHandler<PluginInfrastructureEventArgs> ApplicationStarting;
+    public event EventHandler<PluginInfrastructureEventArgs> ApplicationStarted;
+
+    private string pluginDir;
+
+    private List<PluginDescription> plugins;
+    /// <summary>
+    /// Gets all installed plugins.
+    /// </summary>
+    public IEnumerable<PluginDescription> Plugins {
+      get { return plugins; }
+    }
+
+    private List<ApplicationDescription> applications;
+    /// <summary>
+    /// Gets all installed applications.
+    /// </summary>
+    public IEnumerable<ApplicationDescription> Applications {
+      get { return applications; }
+    }
+
+    private object locker = new object();
+    private bool initialized;
+
+    public PluginManager(string pluginDir) {
+      this.pluginDir = pluginDir;
+      plugins = new List<PluginDescription>();
+      applications = new List<ApplicationDescription>();
+      initialized = false;
+    }
+
+    /// <summary>
+    /// Determines installed plugins and checks if all plugins are loadable.
+    /// </summary>
+    public void DiscoverAndCheckPlugins() {
+      OnInitializing(PluginInfrastructureEventArgs.Empty);
+      AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
+      setup.ApplicationBase = pluginDir;
+      AppDomain pluginDomain = null;
+      try {
+        pluginDomain = AppDomain.CreateDomain("plugin domain", null, setup);
+        Type pluginValidatorType = typeof(PluginValidator);
+        PluginValidator remoteValidator = (PluginValidator)pluginDomain.CreateInstanceAndUnwrap(pluginValidatorType.Assembly.FullName, pluginValidatorType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null);
+        remoteValidator.PluginDir = pluginDir;
+        // forward all events from the remoteValidator to listeners
+        remoteValidator.PluginLoaded +=
+          delegate(object sender, PluginInfrastructureEventArgs e) {
+            OnPluginLoaded(e);
+          };
+        // get list of plugins and applications from the validator
+        plugins.Clear(); applications.Clear();
+        plugins.AddRange(remoteValidator.Plugins);
+        applications.AddRange(remoteValidator.Applications);
+      }
+      finally {
+        // discard the AppDomain that was used for plugin discovery
+        AppDomain.Unload(pluginDomain);
+        // unload all plugins
+        foreach (var pluginDescription in plugins.Where(x => x.PluginState == PluginState.Loaded)) {
+          pluginDescription.Unload();
+          OnPluginUnloaded(new PluginInfrastructureEventArgs(pluginDescription));
+        }
+        initialized = true;
+        OnInitialized(PluginInfrastructureEventArgs.Empty);
+      }
+    }
+
+
+    /// <summary>
+    /// Starts an application in a separate AppDomain.
+    /// Loads all enabled plugins and starts the application via an ApplicationManager instance activated in the new AppDomain.
+    /// </summary>
+    /// <param name="appInfo">application to run</param>
+    public void Run(ApplicationDescription appInfo, ICommandLineArgument[] args) {
+      if (!initialized) throw new InvalidOperationException("PluginManager is not initialized. DiscoverAndCheckPlugins() must be called before Run()");
+      // create a separate AppDomain for the application
+      // initialize the static ApplicationManager in the AppDomain
+      // and remotely tell it to start the application
+
+      OnApplicationStarting(new PluginInfrastructureEventArgs(appInfo));
+      AppDomain applicationDomain = null;
+      try {
+        AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
+        setup.PrivateBinPath = pluginDir;
+        applicationDomain = AppDomain.CreateDomain(AppDomain.CurrentDomain.FriendlyName, null, setup);
+        Type applicationManagerType = typeof(DefaultApplicationManager);
+        DefaultApplicationManager applicationManager =
+          (DefaultApplicationManager)applicationDomain.CreateInstanceAndUnwrap(applicationManagerType.Assembly.FullName, applicationManagerType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null);
+        applicationManager.PluginLoaded += applicationManager_PluginLoaded;
+        applicationManager.PluginUnloaded += applicationManager_PluginUnloaded;
+        applicationManager.PrepareApplicationDomain(applications, plugins);
+        OnApplicationStarted(new PluginInfrastructureEventArgs(appInfo));
+        applicationManager.Run(appInfo, args);
+      }
+      finally {
+        // make sure domain is unloaded in all cases
+        AppDomain.Unload(applicationDomain);
+      }
+    }
+
+    private void applicationManager_PluginUnloaded(object sender, PluginInfrastructureEventArgs e) {
+      // unload the matching plugin description (
+      PluginDescription desc = (PluginDescription)e.Entity;
+
+      // access to plugin descriptions has to be synchronized because multiple applications 
+      // can be started or stopped at the same time
+      lock (locker) {
+        // also unload the matching plugin description in this AppDomain
+        plugins.First(x => x.Equals(desc)).Unload();
+      }
+      OnPluginUnloaded(e);
+    }
+
+    private void applicationManager_PluginLoaded(object sender, PluginInfrastructureEventArgs e) {
+      // load the matching plugin description (
+      PluginDescription desc = (PluginDescription)e.Entity;
+      // access to plugin descriptions has to be synchronized because multiple applications 
+      // can be started or stopped at the same time
+      lock (locker) {
+        // also load the matching plugin description in this AppDomain
+        plugins.First(x => x.Equals(desc)).Load();
+      }
+      OnPluginLoaded(e);
+    }
+
+    #region event raising methods
+    private void OnPluginLoaded(PluginInfrastructureEventArgs e) {
+      if (PluginLoaded != null) {
+        PluginLoaded(this, e);
+      }
+    }
+
+    private void OnPluginUnloaded(PluginInfrastructureEventArgs e) {
+      if (PluginUnloaded != null) {
+        PluginUnloaded(this, e);
+      }
+    }
+
+    private void OnInitializing(PluginInfrastructureEventArgs e) {
+      if (Initializing != null) {
+        Initializing(this, e);
+      }
+    }
+
+    private void OnInitialized(PluginInfrastructureEventArgs e) {
+      if (Initialized != null) {
+        Initialized(this, e);
+      }
+    }
+
+    private void OnApplicationStarting(PluginInfrastructureEventArgs e) {
+      if (ApplicationStarting != null) {
+        ApplicationStarting(this, e);
+      }
+    }
+
+    private void OnApplicationStarted(PluginInfrastructureEventArgs e) {
+      if (ApplicationStarted != null) {
+        ApplicationStarted(this, e);
+      }
+    }
+    #endregion
+
+    // infinite lease time
+    /// <summary>
+    /// Make sure that the plugin manager is never disposed (necessary for cross-app-domain events)
+    /// </summary>
+    /// <returns><c>null</c>.</returns>
+    [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.Infrastructure)]
+    public override object InitializeLifetimeService() {
+      return null;
+    }
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginValidator.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginValidator.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/PluginValidator.cs	(revision 13341)
@@ -0,0 +1,634 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Security;
+using System.Text;
+
+
+namespace HeuristicLab.PluginInfrastructure.Manager {
+  /// <summary>
+  /// Discovers all installed plugins in the plugin directory. Checks correctness of plugin meta-data and if
+  /// all plugin files are available and checks plugin dependencies. 
+  /// </summary>
+  internal sealed class PluginValidator : MarshalByRefObject {
+    // private class to store plugin dependency declarations while reflecting over plugins
+    private class PluginDependency {
+      public string Name { get; private set; }
+      public Version Version { get; private set; }
+
+      public PluginDependency(string name, Version version) {
+        this.Name = name;
+        this.Version = version;
+      }
+    }
+
+
+    internal event EventHandler<PluginInfrastructureEventArgs> PluginLoaded;
+
+    private Dictionary<PluginDescription, IEnumerable<PluginDependency>> pluginDependencies;
+
+    private List<ApplicationDescription> applications;
+    internal IEnumerable<ApplicationDescription> Applications {
+      get {
+        if (string.IsNullOrEmpty(PluginDir)) throw new InvalidOperationException("PluginDir is not set.");
+        if (applications == null) DiscoverAndCheckPlugins();
+        return applications;
+      }
+    }
+
+    private IEnumerable<PluginDescription> plugins;
+    internal IEnumerable<PluginDescription> Plugins {
+      get {
+        if (string.IsNullOrEmpty(PluginDir)) throw new InvalidOperationException("PluginDir is not set.");
+        if (plugins == null) DiscoverAndCheckPlugins();
+        return plugins;
+      }
+    }
+
+    internal string PluginDir { get; set; }
+
+    internal PluginValidator() {
+      this.pluginDependencies = new Dictionary<PluginDescription, IEnumerable<PluginDependency>>();
+
+      // ReflectionOnlyAssemblyResolveEvent must be handled because we load assemblies from the plugin path 
+      // (which is not listed in the default assembly lookup locations)
+      AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += ReflectionOnlyAssemblyResolveEventHandler;
+    }
+
+    private Dictionary<string, Assembly> reflectionOnlyAssemblies = new Dictionary<string, Assembly>();
+    private Assembly ReflectionOnlyAssemblyResolveEventHandler(object sender, ResolveEventArgs args) {
+      if (reflectionOnlyAssemblies.ContainsKey(args.Name))
+        return reflectionOnlyAssemblies[args.Name];
+      else
+        return Assembly.ReflectionOnlyLoad(args.Name);
+    }
+
+
+    /// <summary>
+    /// Init first clears all internal datastructures (including plugin lists)
+    /// 1. All assemblies in the plugins directory are loaded into the reflection only context.
+    /// 2. The validator checks if all necessary files for each plugin are available.
+    /// 3. The validator checks if all declared plugin assemblies can be loaded.
+    /// 4. The validator builds the tree of plugin descriptions (dependencies)
+    /// 5. The validator checks if there are any cycles in the plugin dependency graph and disables plugin with circular dependencies
+    /// 6. The validator checks for each plugin if any dependency is disabled.
+    /// 7. All plugins that are not disabled are loaded into the execution context.
+    /// 8. Each loaded plugin (all assemblies) is searched for a types that implement IPlugin
+    ///    then one instance of each IPlugin type is activated and the OnLoad hook is called.
+    /// 9. All types implementing IApplication are discovered
+    /// </summary>
+    internal void DiscoverAndCheckPlugins() {
+      pluginDependencies.Clear();
+
+      IEnumerable<Assembly> reflectionOnlyAssemblies = ReflectionOnlyLoadDlls(PluginDir);
+      IEnumerable<PluginDescription> pluginDescriptions = GatherPluginDescriptions(reflectionOnlyAssemblies);
+      CheckPluginFiles(pluginDescriptions);
+
+      // check if all plugin assemblies can be loaded
+      CheckPluginAssemblies(pluginDescriptions);
+
+      // a full list of plugin descriptions is available now we can build the dependency tree
+      BuildDependencyTree(pluginDescriptions);
+
+      // check for dependency cycles
+      CheckPluginDependencyCycles(pluginDescriptions);
+
+      // 1st time recursively check if all necessary plugins are available and not disabled
+      // disable plugins with missing or disabled dependencies 
+      // to prevent that plugins with missing dependencies are loaded into the execution context
+      // in the next step
+      CheckPluginDependencies(pluginDescriptions);
+
+      // test full loading (in contrast to reflection only loading) of plugins
+      // disables plugins that are not loaded correctly
+      CheckExecutionContextLoad(pluginDescriptions);
+
+      // 2nd time recursively check if all necessary plugins have been loaded successfully and not disabled
+      // disable plugins with for which dependencies could not be loaded successfully
+      CheckPluginDependencies(pluginDescriptions);
+
+      // mark all plugins as enabled that were not disabled in CheckPluginFiles, CheckPluginAssemblies, 
+      // CheckCircularDependencies, CheckPluginDependencies and CheckExecutionContextLoad
+      foreach (var desc in pluginDescriptions)
+        if (desc.PluginState != PluginState.Disabled)
+          desc.Enable();
+
+      // load the enabled plugins
+      LoadPlugins(pluginDescriptions);
+
+      plugins = pluginDescriptions;
+      DiscoverApplications(pluginDescriptions);
+    }
+
+    private void DiscoverApplications(IEnumerable<PluginDescription> pluginDescriptions) {
+      applications = new List<ApplicationDescription>();
+      foreach (IApplication application in GetApplications(pluginDescriptions)) {
+        Type appType = application.GetType();
+        ApplicationAttribute attr = (from x in appType.GetCustomAttributes(typeof(ApplicationAttribute), false)
+                                     select (ApplicationAttribute)x).Single();
+        ApplicationDescription info = new ApplicationDescription();
+        PluginDescription declaringPlugin = GetDeclaringPlugin(appType, pluginDescriptions);
+        info.Name = application.Name;
+        info.Version = declaringPlugin.Version;
+        info.Description = application.Description;
+        info.AutoRestart = attr.RestartOnErrors;
+        info.DeclaringAssemblyName = appType.Assembly.GetName().Name;
+        info.DeclaringTypeName = appType.Namespace + "." + application.GetType().Name;
+
+        applications.Add(info);
+      }
+    }
+
+    private static IEnumerable<IApplication> GetApplications(IEnumerable<PluginDescription> pluginDescriptions) {
+      return from asm in AppDomain.CurrentDomain.GetAssemblies()
+             from t in asm.GetTypes()
+             where typeof(IApplication).IsAssignableFrom(t) &&
+               !t.IsAbstract && !t.IsInterface && !t.HasElementType
+             where GetDeclaringPlugin(t, pluginDescriptions).PluginState != PluginState.Disabled
+             select (IApplication)Activator.CreateInstance(t);
+    }
+
+    private IEnumerable<Assembly> ReflectionOnlyLoadDlls(string baseDir) {
+      List<Assembly> assemblies = new List<Assembly>();
+      // recursively load .dll files in subdirectories
+      foreach (string dirName in Directory.GetDirectories(baseDir)) {
+        assemblies.AddRange(ReflectionOnlyLoadDlls(dirName));
+      }
+      // try to load each .dll file in the plugin directory into the reflection only context
+      foreach (string filename in Directory.GetFiles(baseDir, "*.dll").Union(Directory.GetFiles(baseDir, "*.exe"))) {
+        try {
+          Assembly asm = Assembly.ReflectionOnlyLoadFrom(filename);
+          RegisterLoadedAssembly(asm);
+          assemblies.Add(asm);
+        }
+        catch (BadImageFormatException) { } // just ignore the case that the .dll file is not a CLR assembly (e.g. a native dll)
+        catch (FileLoadException) { }
+        catch (SecurityException) { }
+        catch (ReflectionTypeLoadException) { } // referenced assemblies are missing
+      }
+      return assemblies;
+    }
+
+    /// <summary>
+    /// Checks if all plugin assemblies can be loaded. If an assembly can't be loaded the plugin is disabled.
+    /// </summary>
+    /// <param name="pluginDescriptions"></param>
+    private void CheckPluginAssemblies(IEnumerable<PluginDescription> pluginDescriptions) {
+      foreach (var desc in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) {
+        try {
+          var missingAssemblies = new List<string>();
+          foreach (var asmLocation in desc.AssemblyLocations) {
+            // the assembly must have been loaded in ReflectionOnlyDlls
+            // so we simply determine the name of the assembly and try to find it in the cache of loaded assemblies
+            var asmName = AssemblyName.GetAssemblyName(asmLocation);
+            if (!reflectionOnlyAssemblies.ContainsKey(asmName.FullName)) {
+              missingAssemblies.Add(asmName.FullName);
+            }
+          }
+          if (missingAssemblies.Count > 0) {
+            StringBuilder errorStrBuiler = new StringBuilder();
+            errorStrBuiler.AppendLine("Missing assemblies:");
+            foreach (string missingAsm in missingAssemblies) {
+              errorStrBuiler.AppendLine(missingAsm);
+            }
+            desc.Disable(errorStrBuiler.ToString());
+          }
+        }
+        catch (BadImageFormatException ex) {
+          // disable the plugin
+          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "BadImageFormatException: " + ex.Message);
+        }
+        catch (FileNotFoundException ex) {
+          // disable the plugin
+          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "FileNotFoundException: " + ex.Message);
+        }
+        catch (FileLoadException ex) {
+          // disable the plugin
+          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "FileLoadException: " + ex.Message);
+        }
+        catch (ArgumentException ex) {
+          // disable the plugin
+          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "ArgumentException: " + ex.Message);
+        }
+        catch (SecurityException ex) {
+          // disable the plugin
+          desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "SecurityException: " + ex.Message);
+        }
+      }
+    }
+
+
+    // find all types implementing IPlugin in the reflectionOnlyAssemblies and create a list of plugin descriptions
+    // the dependencies in the plugin descriptions are not yet set correctly because we need to create
+    // the full list of all plugin descriptions first
+    private IEnumerable<PluginDescription> GatherPluginDescriptions(IEnumerable<Assembly> assemblies) {
+      List<PluginDescription> pluginDescriptions = new List<PluginDescription>();
+      foreach (Assembly assembly in assemblies) {
+        // GetExportedTypes throws FileNotFoundException when a referenced assembly
+        // of the current assembly is missing.
+        try {
+          // if there is a type that implements IPlugin
+          // use AssemblyQualifiedName to compare the types because we can't directly 
+          // compare ReflectionOnly types and execution types
+          var assemblyPluginDescriptions = from t in assembly.GetExportedTypes()
+                                           where !t.IsAbstract && t.GetInterfaces().Any(x => x.AssemblyQualifiedName == typeof(IPlugin).AssemblyQualifiedName)
+                                           select GetPluginDescription(t);
+          pluginDescriptions.AddRange(assemblyPluginDescriptions);
+        }
+        // ignore exceptions. Just don't yield a plugin description when an exception is thrown
+        catch (FileNotFoundException) {
+        }
+        catch (FileLoadException) {
+        }
+        catch (InvalidPluginException) {
+        }
+        catch (TypeLoadException) {
+        }
+        catch (MissingMemberException) {
+        }
+      }
+      return pluginDescriptions;
+    }
+
+    /// <summary>
+    /// Extracts plugin information for this type.
+    /// Reads plugin name, list and type of files and dependencies of the plugin. This information is necessary for
+    /// plugin dependency checking before plugin activation.
+    /// </summary>
+    /// <param name="pluginType"></param>
+    private PluginDescription GetPluginDescription(Type pluginType) {
+
+      string pluginName, pluginDescription, pluginVersion;
+      string contactName, contactAddress;
+      GetPluginMetaData(pluginType, out pluginName, out pluginDescription, out pluginVersion);
+      GetPluginContactMetaData(pluginType, out contactName, out contactAddress);
+      var pluginFiles = GetPluginFilesMetaData(pluginType);
+      var pluginDependencies = GetPluginDependencyMetaData(pluginType);
+
+      // minimal sanity check of the attribute values
+      if (!string.IsNullOrEmpty(pluginName) &&
+          pluginFiles.Count() > 0 &&                                 // at least one file
+          pluginFiles.Any(f => f.Type == PluginFileType.Assembly)) { // at least one assembly
+        // create a temporary PluginDescription that contains the attribute values
+        PluginDescription info = new PluginDescription();
+        info.Name = pluginName;
+        info.Description = pluginDescription;
+        info.Version = new Version(pluginVersion);
+        info.ContactName = contactName;
+        info.ContactEmail = contactAddress;
+        info.LicenseText = ReadLicenseFiles(pluginFiles);
+        info.AddFiles(pluginFiles);
+
+        this.pluginDependencies[info] = pluginDependencies;
+        return info;
+      } else {
+        throw new InvalidPluginException("Invalid metadata in plugin " + pluginType.ToString());
+      }
+    }
+
+    private static string ReadLicenseFiles(IEnumerable<PluginFile> pluginFiles) {
+      // combine the contents of all plugin files 
+      var licenseFiles = from file in pluginFiles
+                         where file.Type == PluginFileType.License
+                         select file;
+      if (licenseFiles.Count() == 0) return string.Empty;
+      StringBuilder licenseTextBuilder = new StringBuilder();
+      licenseTextBuilder.AppendLine(File.ReadAllText(licenseFiles.First().Name));
+      foreach (var licenseFile in licenseFiles.Skip(1)) {
+        licenseTextBuilder.AppendLine().AppendLine(); // leave some empty space between multiple license files
+        licenseTextBuilder.AppendLine(File.ReadAllText(licenseFile.Name));
+      }
+      return licenseTextBuilder.ToString();
+    }
+
+    private static IEnumerable<PluginDependency> GetPluginDependencyMetaData(Type pluginType) {
+      // get all attributes of type PluginDependency
+      var dependencyAttributes = from attr in CustomAttributeData.GetCustomAttributes(pluginType)
+                                 where IsAttributeDataForType(attr, typeof(PluginDependencyAttribute))
+                                 select attr;
+
+      foreach (var dependencyAttr in dependencyAttributes) {
+        string name = (string)dependencyAttr.ConstructorArguments[0].Value;
+        Version version = new Version("0.0.0.0"); // default version
+        // check if version is given for now
+        // later when the constructor of PluginDependencyAttribute with only one argument has been removed
+        // this conditional can be removed as well
+        if (dependencyAttr.ConstructorArguments.Count > 1) {
+          try {
+            version = new Version((string)dependencyAttr.ConstructorArguments[1].Value); // might throw FormatException
+          }
+          catch (FormatException ex) {
+            throw new InvalidPluginException("Invalid version format of dependency " + name + " in plugin " + pluginType.ToString(), ex);
+          }
+        }
+        yield return new PluginDependency(name, version);
+      }
+    }
+
+    private static void GetPluginContactMetaData(Type pluginType, out string contactName, out string contactAddress) {
+      // get attribute of type ContactInformation if there is any
+      var contactInfoAttribute = (from attr in CustomAttributeData.GetCustomAttributes(pluginType)
+                                  where IsAttributeDataForType(attr, typeof(ContactInformationAttribute))
+                                  select attr).SingleOrDefault();
+
+      if (contactInfoAttribute != null) {
+        contactName = (string)contactInfoAttribute.ConstructorArguments[0].Value;
+        contactAddress = (string)contactInfoAttribute.ConstructorArguments[1].Value;
+      } else {
+        contactName = string.Empty;
+        contactAddress = string.Empty;
+      }
+    }
+
+    // not static because we need the PluginDir property
+    private IEnumerable<PluginFile> GetPluginFilesMetaData(Type pluginType) {
+      // get all attributes of type PluginFileAttribute
+      var pluginFileAttributes = from attr in CustomAttributeData.GetCustomAttributes(pluginType)
+                                 where IsAttributeDataForType(attr, typeof(PluginFileAttribute))
+                                 select attr;
+      foreach (var pluginFileAttribute in pluginFileAttributes) {
+        string pluginFileName = (string)pluginFileAttribute.ConstructorArguments[0].Value;
+        PluginFileType fileType = (PluginFileType)pluginFileAttribute.ConstructorArguments[1].Value;
+        yield return new PluginFile(Path.GetFullPath(Path.Combine(PluginDir, pluginFileName)), fileType);
+      }
+    }
+
+    private static void GetPluginMetaData(Type pluginType, out string pluginName, out string pluginDescription, out string pluginVersion) {
+      // there must be a single attribute of type PluginAttribute
+      var pluginMetaDataAttr = (from attr in CustomAttributeData.GetCustomAttributes(pluginType)
+                                where IsAttributeDataForType(attr, typeof(PluginAttribute))
+                                select attr).Single();
+
+      pluginName = (string)pluginMetaDataAttr.ConstructorArguments[0].Value;
+
+      // default description and version
+      pluginVersion = "0.0.0.0";
+      pluginDescription = string.Empty;
+      if (pluginMetaDataAttr.ConstructorArguments.Count() == 2) {
+        // if two arguments are given the second argument is the version
+        pluginVersion = (string)pluginMetaDataAttr.ConstructorArguments[1].Value;
+      } else if (pluginMetaDataAttr.ConstructorArguments.Count() == 3) {
+        // if three arguments are given the second argument is the description and the third is the version
+        pluginDescription = (string)pluginMetaDataAttr.ConstructorArguments[1].Value;
+        pluginVersion = (string)pluginMetaDataAttr.ConstructorArguments[2].Value;
+      }
+    }
+
+    private static bool IsAttributeDataForType(CustomAttributeData attributeData, Type attributeType) {
+      return attributeData.Constructor.DeclaringType.AssemblyQualifiedName == attributeType.AssemblyQualifiedName;
+    }
+
+    // builds a dependency tree of all plugin descriptions
+    // searches matching plugin descriptions based on the list of dependency names for each plugin
+    // and sets the dependencies in the plugin descriptions
+    private void BuildDependencyTree(IEnumerable<PluginDescription> pluginDescriptions) {
+      foreach (var desc in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) {
+        var missingDependencies = new List<PluginDependency>();
+        foreach (var dependency in pluginDependencies[desc]) {
+          var matchingDescriptions = from availablePlugin in pluginDescriptions
+                                     where availablePlugin.PluginState != PluginState.Disabled
+                                     where availablePlugin.Name == dependency.Name
+                                     where IsCompatiblePluginVersion(availablePlugin.Version, dependency.Version)
+                                     select availablePlugin;
+          if (matchingDescriptions.Count() > 0) {
+            desc.AddDependency(matchingDescriptions.Single());
+          } else {
+            missingDependencies.Add(dependency);
+          }
+        }
+        // no plugin description that matches the dependencies are available => plugin is disabled
+        if (missingDependencies.Count > 0) {
+          StringBuilder errorStrBuilder = new StringBuilder();
+          errorStrBuilder.AppendLine("Missing dependencies:");
+          foreach (var missingDep in missingDependencies) {
+            errorStrBuilder.AppendLine(missingDep.Name + " " + missingDep.Version);
+          }
+          desc.Disable(errorStrBuilder.ToString());
+        }
+      }
+    }
+
+    /// <summary>
+    /// Checks if version <paramref name="available"/> is compatible to version <paramref name="requested"/>.
+    /// Note: the compatibility relation is not bijective.
+    /// Compatibility rules:
+    ///  * major and minor number must be the same
+    ///  * build and revision number of <paramref name="available"/> must be larger or equal to <paramref name="requested"/>.
+    /// </summary>
+    /// <param name="available">The available version which should be compared to <paramref name="requested"/>.</param>
+    /// <param name="requested">The requested version that must be matched.</param>
+    /// <returns></returns>
+    private static bool IsCompatiblePluginVersion(Version available, Version requested) {
+      // this condition must be removed after all plugins have been updated to declare plugin and dependency versions
+      if (
+        (requested.Major == 0 && requested.Minor == 0) ||
+        (available.Major == 0 && available.Minor == 0)) return true;
+      return
+        available.Major == requested.Major &&
+        available.Minor == requested.Minor &&
+        available.Build >= requested.Build &&
+        available.Revision >= requested.Revision;
+    }
+
+    private void CheckPluginDependencyCycles(IEnumerable<PluginDescription> pluginDescriptions) {
+      foreach (var plugin in pluginDescriptions) {
+        // if the plugin is not disabled check if there are cycles
+        if (plugin.PluginState != PluginState.Disabled && HasCycleInDependencies(plugin, plugin.Dependencies)) {
+          plugin.Disable("Dependency graph has a cycle.");
+        }
+      }
+    }
+
+    private bool HasCycleInDependencies(PluginDescription plugin, IEnumerable<PluginDescription> pluginDependencies) {
+      foreach (var dep in pluginDependencies) {
+        // if one of the dependencies is the original plugin we found a cycle and can return
+        // if the dependency is already disabled we can ignore the cycle detection because we will disable the plugin anyway
+        // if following one of the dependencies recursively leads to a cycle then we also return
+        if (dep == plugin || dep.PluginState == PluginState.Disabled || HasCycleInDependencies(plugin, dep.Dependencies)) return true;
+      }
+      // no cycle found and none of the direct and indirect dependencies is disabled
+      return false;
+    }
+
+    private void CheckPluginDependencies(IEnumerable<PluginDescription> pluginDescriptions) {
+      foreach (PluginDescription pluginDescription in pluginDescriptions.Where(x => x.PluginState != PluginState.Disabled)) {
+        List<PluginDescription> disabledPlugins = new List<PluginDescription>();
+        if (IsAnyDependencyDisabled(pluginDescription, disabledPlugins)) {
+          StringBuilder errorStrBuilder = new StringBuilder();
+          errorStrBuilder.AppendLine("Dependencies are disabled:");
+          foreach (var disabledPlugin in disabledPlugins) {
+            errorStrBuilder.AppendLine(disabledPlugin.Name + " " + disabledPlugin.Version);
+          }
+          pluginDescription.Disable(errorStrBuilder.ToString());
+        }
+      }
+    }
+
+
+    private bool IsAnyDependencyDisabled(PluginDescription descr, List<PluginDescription> disabledPlugins) {
+      if (descr.PluginState == PluginState.Disabled) {
+        disabledPlugins.Add(descr);
+        return true;
+      }
+      foreach (PluginDescription dependency in descr.Dependencies) {
+        IsAnyDependencyDisabled(dependency, disabledPlugins);
+      }
+      return disabledPlugins.Count > 0;
+    }
+
+    // tries to load all plugin assemblies into the execution context
+    // if an assembly of a plugin cannot be loaded the plugin is disabled
+    private void CheckExecutionContextLoad(IEnumerable<PluginDescription> pluginDescriptions) {
+      // load all loadable plugins (all dependencies available) into the execution context
+      foreach (var desc in PluginDescriptionIterator.IterateDependenciesBottomUp(pluginDescriptions
+                                                                                .Where(x => x.PluginState != PluginState.Disabled))) {
+        // store the assembly names so that we can later retrieve the assemblies loaded in the appdomain by name
+        var assemblyNames = new List<string>();
+        foreach (string assemblyLocation in desc.AssemblyLocations) {
+          if (desc.PluginState != PluginState.Disabled) {
+            try {
+              string assemblyName = (from assembly in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()
+                                     where string.Equals(Path.GetFullPath(assembly.Location), Path.GetFullPath(assemblyLocation), StringComparison.CurrentCultureIgnoreCase)
+                                     select assembly.FullName).Single();
+              // now load the assemblies into the execution context  
+              // this can still lead to an exception
+              // even when the assemby was successfully loaded into the reflection only context before 
+              // when loading the assembly using it's assemblyName it can be loaded from a different location than before (e.g. the GAC)
+              Assembly.Load(assemblyName);
+              assemblyNames.Add(assemblyName);
+            }
+            catch (BadImageFormatException) {
+              desc.Disable(Path.GetFileName(assemblyLocation) + " is not a valid assembly.");
+            }
+            catch (FileLoadException) {
+              desc.Disable("Can't load file " + Path.GetFileName(assemblyLocation));
+            }
+            catch (FileNotFoundException) {
+              desc.Disable("File " + Path.GetFileName(assemblyLocation) + " is missing.");
+            }
+            catch (SecurityException) {
+              desc.Disable("File " + Path.GetFileName(assemblyLocation) + " can't be loaded because of security constraints.");
+            }
+            catch (NotSupportedException ex) {
+              // disable the plugin
+              desc.Disable("Problem while loading plugin assemblies:" + Environment.NewLine + "NotSupportedException: " + ex.Message);
+            }
+          }
+        }
+        desc.AssemblyNames = assemblyNames;
+      }
+    }
+
+    // assumes that all plugin assemblies have been loaded into the execution context via CheckExecutionContextLoad
+    // for each enabled plugin:
+    // calls OnLoad method of the plugin 
+    // and raises the PluginLoaded event
+    private void LoadPlugins(IEnumerable<PluginDescription> pluginDescriptions) {
+      List<Assembly> assemblies = new List<Assembly>(AppDomain.CurrentDomain.GetAssemblies());
+      foreach (var desc in pluginDescriptions) {
+        if (desc.PluginState == PluginState.Enabled) {
+          // cannot use ApplicationManager to retrieve types because it is not yet instantiated
+          foreach (string assemblyName in desc.AssemblyNames) {
+            var asm = (from assembly in assemblies
+                       where assembly.FullName == assemblyName
+                       select assembly)
+                      .SingleOrDefault();
+            if (asm == null) throw new InvalidPluginException("Could not load assembly " + assemblyName + " for plugin " + desc.Name);
+            foreach (Type pluginType in asm.GetTypes()) {
+              if (typeof(IPlugin).IsAssignableFrom(pluginType) && !pluginType.IsAbstract && !pluginType.IsInterface && !pluginType.HasElementType) {
+                IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType);
+                plugin.OnLoad();
+                OnPluginLoaded(new PluginInfrastructureEventArgs(desc));
+              }
+            }
+          } // end foreach assembly in plugin
+          desc.Load();
+        }
+      } // end foreach plugin description
+    }
+
+    // checks if all declared plugin files are actually available and disables plugins with missing files
+    private void CheckPluginFiles(IEnumerable<PluginDescription> pluginDescriptions) {
+      foreach (PluginDescription desc in pluginDescriptions) {
+        IEnumerable<string> missingFiles;
+        if (ArePluginFilesMissing(desc, out missingFiles)) {
+          StringBuilder errorStrBuilder = new StringBuilder();
+          errorStrBuilder.AppendLine("Missing files:");
+          foreach (string fileName in missingFiles) {
+            errorStrBuilder.AppendLine(fileName);
+          }
+          desc.Disable(errorStrBuilder.ToString());
+        }
+      }
+    }
+
+    private bool ArePluginFilesMissing(PluginDescription pluginDescription, out IEnumerable<string> missingFiles) {
+      List<string> missing = new List<string>();
+      foreach (string filename in pluginDescription.Files.Select(x => x.Name)) {
+        if (!FileLiesInDirectory(PluginDir, filename) ||
+          !File.Exists(filename)) {
+          missing.Add(filename);
+        }
+      }
+      missingFiles = missing;
+      return missing.Count > 0;
+    }
+
+    private static bool FileLiesInDirectory(string dir, string fileName) {
+      var basePath = Path.GetFullPath(dir);
+      return Path.GetFullPath(fileName).StartsWith(basePath);
+    }
+
+    private static PluginDescription GetDeclaringPlugin(Type appType, IEnumerable<PluginDescription> plugins) {
+      return (from p in plugins
+              from asmLocation in p.AssemblyLocations
+              where Path.GetFullPath(asmLocation).Equals(Path.GetFullPath(appType.Assembly.Location), StringComparison.CurrentCultureIgnoreCase)
+              select p).Single();
+    }
+
+    // register assembly in the assembly cache for the ReflectionOnlyAssemblyResolveEvent
+    private void RegisterLoadedAssembly(Assembly asm) {
+      if (reflectionOnlyAssemblies.ContainsKey(asm.FullName) || reflectionOnlyAssemblies.ContainsKey(asm.GetName().Name)) {
+        throw new ArgumentException("An assembly with the name " + asm.GetName().Name + " has been registered already.", "asm");
+      }
+      reflectionOnlyAssemblies.Add(asm.FullName, asm);
+      reflectionOnlyAssemblies.Add(asm.GetName().Name, asm); // add short name
+    }
+
+    private void OnPluginLoaded(PluginInfrastructureEventArgs e) {
+      if (PluginLoaded != null)
+        PluginLoaded(this, e);
+    }
+
+    /// <summary>
+    /// Initializes the life time service with an infinite lease time.
+    /// </summary>
+    /// <returns><c>null</c>.</returns>
+    public override object InitializeLifetimeService() {
+      return null;
+    }
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/SandboxManager.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/SandboxManager.cs	(revision 13341)
+++ branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/SandboxManager.cs	(revision 13341)
@@ -0,0 +1,54 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using HeuristicLab.PluginInfrastructure.Manager;
+
+namespace HeuristicLab.PluginInfrastructure.Sandboxing {
+  // used by Hive Slave
+  public static class SandboxManager {
+    /// <summary>
+    /// Returns a new AppDomain with loaded assemblies/plugins from applicationBase
+    /// </summary>    
+    public static AppDomain CreateAndInitSandbox(string appDomainName, string applicationBase, string configFilePath) {
+      PermissionSet pSet;
+      pSet = new PermissionSet(PermissionState.Unrestricted);
+
+      AppDomainSetup setup = new AppDomainSetup();
+      setup.PrivateBinPath = applicationBase;
+      setup.ApplicationBase = applicationBase;
+      setup.ConfigurationFile = configFilePath;
+
+      Type applicationManagerType = typeof(DefaultApplicationManager);
+      AppDomain applicationDomain = AppDomain.CreateDomain(appDomainName, null, setup, pSet, null);
+      DefaultApplicationManager applicationManager = (DefaultApplicationManager)applicationDomain.CreateInstanceAndUnwrap(applicationManagerType.Assembly.FullName, applicationManagerType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null);
+
+      PluginManager pm = new PluginManager(applicationBase);
+      pm.DiscoverAndCheckPlugins();
+      applicationManager.PrepareApplicationDomain(pm.Applications, pm.Plugins);
+
+      return applicationDomain;
+    }
+  }
+}
Index: branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Sandboxing/SandboxManager.cs
===================================================================
--- branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Sandboxing/SandboxManager.cs	(revision 13340)
+++ 	(revision )
@@ -1,54 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Reflection;
-using System.Security;
-using System.Security.Permissions;
-using HeuristicLab.PluginInfrastructure.Manager;
-
-namespace HeuristicLab.PluginInfrastructure.Sandboxing {
-  // used by Hive Slave
-  public static class SandboxManager {
-    /// <summary>
-    /// Returns a new AppDomain with loaded assemblies/plugins from applicationBase
-    /// </summary>    
-    public static AppDomain CreateAndInitSandbox(string appDomainName, string applicationBase, string configFilePath) {
-      PermissionSet pSet;
-      pSet = new PermissionSet(PermissionState.Unrestricted);
-
-      AppDomainSetup setup = new AppDomainSetup();
-      setup.PrivateBinPath = applicationBase;
-      setup.ApplicationBase = applicationBase;
-      setup.ConfigurationFile = configFilePath;
-
-      Type applicationManagerType = typeof(DefaultApplicationManager);
-      AppDomain applicationDomain = AppDomain.CreateDomain(appDomainName, null, setup, pSet, null);
-      DefaultApplicationManager applicationManager = (DefaultApplicationManager)applicationDomain.CreateInstanceAndUnwrap(applicationManagerType.Assembly.FullName, applicationManagerType.FullName, true, BindingFlags.NonPublic | BindingFlags.Instance, null, null, null, null);
-
-      PluginManager pm = new PluginManager(applicationBase);
-      pm.DiscoverAndCheckPlugins();
-      applicationManager.PrepareApplicationDomain(pm.Applications, pm.Plugins);
-
-      return applicationDomain;
-    }
-  }
-}
