Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/ApplicationManager.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/ApplicationManager.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/ApplicationManager.cs	(revision 2489)
@@ -31,5 +31,10 @@
 namespace HeuristicLab.PluginInfrastructure.Manager {
 
-  public class ApplicationManager : MarshalByRefObject, IApplicationManager {
+  public class DefaultApplicationManager : MarshalByRefObject, IApplicationManager {
+    internal event EventHandler<PluginInfrastructureEventArgs> PluginLoaded;
+    // cache for the AssemblyResolveEvent 
+    // which must be handled when assemblies are loaded dynamically after the application start
+    private Dictionary<string, Assembly> loadedAssemblies;
+
     private List<IPluginDescription> plugins;
     /// <summary>
@@ -48,5 +53,15 @@
     }
 
-    public ApplicationManager() : base() { }
+    public DefaultApplicationManager()
+      : base() {
+      loadedAssemblies = new Dictionary<string, Assembly>();
+      // needed for the special case when assemblies are loaded dynamically via LoadAssemblies()
+      AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
+        if (loadedAssemblies.ContainsKey(args.Name)) {
+          return loadedAssemblies[args.Name];
+        }
+        return null;
+      };
+    }
 
     internal void PrepareApplicationDomain(IEnumerable<IApplicationDescription> apps, IEnumerable<IPluginDescription> plugins) {
@@ -62,4 +77,5 @@
         foreach (var plugin in GetInstances<IPlugin>(desc)) {
           plugin.OnLoad();
+          FirePluginLoaded(plugin.Name);
         }
         desc.Load();
@@ -85,4 +101,21 @@
 
     /// <summary>
+    /// Loads assemblies dynamically from a byte array
+    /// </summary>
+    /// <param name="plugins">bytearray of all assemblies that should be loaded</param>
+    public void LoadAssemblies(IEnumerable<byte[]> assemblies) {
+      foreach (byte[] asm in assemblies) {
+        Assembly loadedAsm = Assembly.Load(asm);
+        RegisterLoadedAssembly(loadedAsm);
+      }
+    }
+
+    // register assembly in the assembly cache for the AssemblyResolveEvent
+    private void RegisterLoadedAssembly(Assembly asm) {
+      loadedAssemblies.Add(asm.FullName, asm);
+      loadedAssemblies.Add(asm.GetName().Name, asm); // add short name
+    }
+
+    /// <summary>
     /// Creates an instance of all types that are subtypes or the same type of the specified type and declared in <paramref name="plugin"/>
     /// </summary>
@@ -134,8 +167,9 @@
     /// <returns>Enumerable of the discovered types.</returns>
     public IEnumerable<Type> GetTypes(Type type, IPluginDescription pluginDescription) {
-      return from asm in AppDomain.CurrentDomain.GetAssemblies()
-             where pluginDescription.Assemblies.Contains(asm.Location)
-             from t in GetTypes(type, asm)
-             select t;
+      throw new NotImplementedException();
+      //return from asm in AppDomain.CurrentDomain.GetAssemblies()
+      //       where pluginDescription.Assemblies.Contains(asm.Location)
+      //       from t in GetTypes(type, asm)
+      //       select t;
     }
 
@@ -152,4 +186,7 @@
     }
 
+    private void FirePluginLoaded(string name) {
+      if (PluginLoaded != null) PluginLoaded(this, new PluginInfrastructureEventArgs("Plugin loaded", name));
+    }
 
     // infinite lease time
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/HeuristicLab.PluginInfrastructure.Manager.csproj
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/HeuristicLab.PluginInfrastructure.Manager.csproj	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/HeuristicLab.PluginInfrastructure.Manager.csproj	(revision 2489)
@@ -54,6 +54,6 @@
     <Compile Include="Loader.cs" />
     <Compile Include="PluginDescription.cs" />
+    <Compile Include="PluginInfrastructureEventArgs.cs" />
     <Compile Include="PluginManager.cs" />
-    <Compile Include="PluginManagerActionEventArgs.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
   </ItemGroup>
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/Loader.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/Loader.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/Loader.cs	(revision 2489)
@@ -31,5 +31,5 @@
 namespace HeuristicLab.PluginInfrastructure.Manager {
   internal class Loader : MarshalByRefObject {
-    internal event PluginManagerActionEventHandler PluginAction;
+    internal event EventHandler<PluginInfrastructureEventArgs> PluginLoaded;
 
     private Dictionary<PluginDescription, List<string>> pluginDependencies;
@@ -163,33 +163,9 @@
           }
         }
-        catch (FileNotFoundException ex) {
-          //PluginDescription info = new PluginDescription();
-          //AssemblyName name = assembly.GetName();
-          //info.Name = name.Name;
-          //info.Version = name.Version;
-          //info.Assemblies.Add(assembly.FullName);
-          //info.Files.Add(assembly.Location);
-          //info.Message = "File not found: " + ex.FileName;
-          //disabledPlugins.Add(info);
-        }
-        catch (FileLoadException ex) {
-          //PluginDescription info = new PluginDescription();
-          //AssemblyName name = assembly.GetName();
-          //info.Name = name.Name;
-          //info.Version = name.Version;
-          //info.Files.Add(assembly.Location);
-          //info.Assemblies.Add(assembly.FullName);
-          //info.Message = "Couldn't load file: " + ex.FileName;
-          //disabledPlugins.Add(info);
-        }
-        catch (InvalidPluginException ex) {
-          //PluginDescription info = new PluginDescription();
-          //AssemblyName name = assembly.GetName();
-          //info.Name = name.Name;
-          //info.Version = name.Version;
-          //info.Files.Add(assembly.Location);
-          //info.Assemblies.Add(assembly.FullName);
-          //info.Message = "Couldn't load plugin class from assembly: " + assembly.GetName().Name + ". Necessary plugin attributes are missing.";
-          //disabledPlugins.Add(info);
+        catch (FileNotFoundException) {
+        }
+        catch (FileLoadException) {
+        }
+        catch (InvalidPluginException) {
         }
       }
@@ -303,46 +279,10 @@
             IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType);
             plugin.OnLoad();
-            desc.Load();
-            PluginAction(this, new PluginManagerActionEventArgs(plugin.Name, PluginManagerAction.PluginLoaded));
-          }
-        }
-      }
-    }
-    //private PluginDescription GetPluginDescription(IPlugin plugin) {
-    //  if (PluginDescriptions.ContainsKey(plugin)) {
-    //    return PluginDescriptions[plugin];
-    //  }
-    //  // store the data of the plugin in a description file which can be used without loading the plugin assemblies
-    //  PluginDescription PluginDescription = new PluginDescription();
-    //  PluginDescription.Name = plugin.Name;
-    //  PluginDescription.Version = plugin.Version;
-
-    //  object[] customAttributes = plugin.GetType().Assembly.GetCustomAttributes(typeof(AssemblyBuildDateAttribute), false);
-    //  if (customAttributes.Length > 0) {
-    //    PluginDescription.BuildDate = ((AssemblyBuildDateAttribute)customAttributes[0]).BuildDate;
-    //  }
-
-    //  string baseDir = AppDomain.CurrentDomain.BaseDirectory;
-
-    //  Array.ForEach<string>(plugin.FileNames, delegate(string file) {
-    //    string filename = pluginDir + "/" + file;
-    //    // always use \ as the directory separator
-    //    PluginDescription.Files.Add(filename.Replace('/', '\\'));
-    //  });
-
-    //  PluginDescription preloadedInfo = preloadedPluginDescriptions.Find(delegate(PluginDescription info) { return info.Name == plugin.Name; });
-    //  foreach (string assembly in preloadedInfo.Assemblies) {
-    //    // always use \ as directory separator (this is necessary for discovery of types in 
-    //    // plugins see DiscoveryService.GetTypes() 
-    //    PluginDescription.Assemblies.Add(assembly.Replace('/', '\\'));
-    //  }
-    //  foreach (string dependency in pluginDependencies[preloadedInfo]) {
-    //    // accumulate the dependencies of each assembly into the dependencies of the whole plugin
-    //    PluginDescription dependencyInfo = GetPluginDescription(pluginsByName[dependency]);
-    //    PluginDescription.Dependencies.Add(dependencyInfo);
-    //  }
-    //  PluginDescriptions[plugin] = PluginDescription;
-    //  return PluginDescription;
-    //}
+            FirePluginLoaded(plugin.Name);
+          }
+        }
+        desc.Load();
+      }
+    }
 
     // checks if all declared plugin files are actually available and disables plugins with missing files
@@ -350,5 +290,4 @@
       foreach (PluginDescription desc in pluginDescriptions) {
         if (!CheckPluginFiles(desc)) {
-          //plugin.Message = "Disabled: missing plugin file.";
           desc.Disable();
         }
@@ -359,11 +298,13 @@
       foreach (string filename in PluginDescription.Files) {
         if (!File.Exists(filename)) {
-          //if (MissingPluginFile != null) {
-          //  MissingPluginFile(PluginDescription.Name, filename);
-          //}
           return false;
         }
       }
       return true;
+    }
+
+    private void FirePluginLoaded(string pluginName) {
+      if (PluginLoaded != null)
+        PluginLoaded(this, new PluginInfrastructureEventArgs("Plugin loaded", pluginName));
     }
 
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginInfrastructureEventArgs.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginInfrastructureEventArgs.cs	(revision 2489)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginInfrastructureEventArgs.cs	(revision 2489)
@@ -0,0 +1,37 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 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.Text;
+
+namespace HeuristicLab.PluginInfrastructure {
+  // to be replaced by GenericEventArgs
+  [Serializable]
+  public class PluginInfrastructureEventArgs : EventArgs {
+    public string Action { get; private set; }
+    public string EntityName { get; private set; }
+    public PluginInfrastructureEventArgs(string action, string entityName) {
+      Action = action;
+      EntityName = entityName;
+    }
+  }
+}
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginManager.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginManager.cs	(revision 2488)
+++ branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginManager.cs	(revision 2489)
@@ -39,5 +39,5 @@
     /// Event handler for actions in the plugin manager.
     /// </summary>
-    public event PluginManagerActionEventHandler Action;
+    public event EventHandler<PluginInfrastructureEventArgs> Action;
 
     private string pluginDir;
@@ -98,5 +98,5 @@
     /// </summary>
     public void Initialize() {
-      NotifyListeners(PluginManagerAction.Initializing, "-");
+      NotifyListeners("Initializing", "PluginInfrastructure");
       AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
       setup.PrivateBinPath = pluginDir;
@@ -104,7 +104,7 @@
       Loader remoteLoader = (Loader)pluginDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfraStructure.Manager", "HeuristicLab.PluginInfrastructure.Manager.Loader");
       remoteLoader.PluginDir = pluginDir;
-      remoteLoader.PluginAction += delegate(object sender, PluginManagerActionEventArgs args) { if (Action != null) Action(this, args); };
+      remoteLoader.PluginLoaded += delegate(object sender, PluginInfrastructureEventArgs args) { NotifyListeners(args.Action, args.EntityName); }; // forward all events from the remoteLoader to listeners
       remoteLoader.Init();
-      NotifyListeners(PluginManagerAction.Initialized, "-");
+      NotifyListeners("Initialized", "PluginInfrastructure");
 
       plugins = new List<PluginDescription>(remoteLoader.Plugins);
@@ -144,5 +144,5 @@
       // and remotely tell it to start the application
 
-      NotifyListeners(PluginManagerAction.ApplicationStart, appInfo.Name);
+      NotifyListeners("Starting application", appInfo.Name);
       AppDomain applicationDomain = null;
       try {
@@ -150,11 +150,11 @@
         setup.PrivateBinPath = pluginDir;
         applicationDomain = AppDomain.CreateDomain(appInfo.Name, null, setup);
-        ApplicationManager applicationManager =
-          (ApplicationManager)applicationDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfraStructure.Manager", "HeuristicLab.PluginInfrastructure.Manager.ApplicationManager");
-        //applicationManager.PluginAction += delegate(object sender, PluginManagerActionEventArgs args) { if (Action != null) Action(this, args); };
+        DefaultApplicationManager applicationManager =
+          (DefaultApplicationManager)applicationDomain.CreateInstanceAndUnwrap("HeuristicLab.PluginInfraStructure.Manager", "HeuristicLab.PluginInfrastructure.Manager.DefaultApplicationManager");
+        applicationManager.PluginLoaded += delegate(object sender, PluginInfrastructureEventArgs args) { NotifyListeners(args.Action, args.EntityName); };
         applicationManager.PrepareApplicationDomain(
           new List<IApplicationDescription>(applications.Cast<IApplicationDescription>()),
           new List<IPluginDescription>(plugins.Cast<IPluginDescription>()));
-        NotifyListeners(PluginManagerAction.Initialized, "All plugins");
+        NotifyListeners("Started application", appInfo.Name);
         applicationManager.Run(appInfo);
       }
@@ -259,7 +259,7 @@
     //}
 
-    private void NotifyListeners(PluginManagerAction action, string text) {
+    private void NotifyListeners(string action, string entityName) {
       if (Action != null) {
-        Action(this, new PluginManagerActionEventArgs(text, action));
+        Action(this, new PluginInfrastructureEventArgs(action, entityName));
       }
     }
Index: branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginManagerActionEventArgs.cs
===================================================================
--- branches/PluginInfrastructure Refactoring/HeuristicLab.PluginInfrastructure.Manager/PluginManagerActionEventArgs.cs	(revision 2488)
+++ 	(revision )
@@ -1,71 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 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.Text;
-
-namespace HeuristicLab.PluginInfrastructure.Manager {
-  public enum PluginManagerAction { Initializing, PluginLoaded, ApplicationStart, Initialized }
-
-
-  /// <summary>
-  /// Event handler for all action events of the plugin manager.
-  /// </summary>
-  /// <param name="sender">The sender of the action event.</param>
-  /// <param name="e">The event arguments.</param>
-  public delegate void PluginManagerActionEventHandler(object sender, PluginManagerActionEventArgs e);
-
-  // this class must be serializable because EventArgs are transmitted over AppDomain boundaries
-  /// <summary>
-  /// Class for the event arguments of plugin manager action events.
-  /// </summary>
-  [Serializable]
-  public class PluginManagerActionEventArgs {
-    private PluginManagerAction action;
-    /// <summary>
-    /// Gets or sets the action that has been performed.
-    /// </summary>
-    public PluginManagerAction Action {
-      get { return action; }
-      set { this.action = value; }
-    }
-    private string id;
-    /// <summary>
-    /// Gets or sets the id of the action event arguments.
-    /// </summary>
-    public string Id {
-      get { return id; }
-      set { id = value; }
-    }
-
-    /// <summary>
-    /// Initializes a new instance of <see cref="PluginManagerActionEventArgs"/> with the given 
-    /// <paramref name="id"/> and <paramref name="action"/>.
-    /// </summary>
-    /// <param name="id">The id of the action event arguments.</param>
-    /// <param name="action">The action of the plugin manager.</param>
-    public PluginManagerActionEventArgs(string id, PluginManagerAction action) {
-      this.Id = id;
-      this.Action = action;
-    }
-  }
-}
