Index: /trunk/sources/HeuristicLab.Clients.Common/3.3/ClientFactory.cs
===================================================================
--- /trunk/sources/HeuristicLab.Clients.Common/3.3/ClientFactory.cs	(revision 4912)
+++ /trunk/sources/HeuristicLab.Clients.Common/3.3/ClientFactory.cs	(revision 4913)
@@ -23,4 +23,8 @@
 using System.ServiceModel;
 using HeuristicLab.Clients.Common.Properties;
+using System.ServiceModel.Description;
+using System.Collections;
+using System.Collections.Generic;
+using HeuristicLab.Common;
 
 namespace HeuristicLab.Clients.Common {
@@ -39,4 +43,9 @@
       where T : ClientBase<I>, I
       where I : class {
+      return CreateClient<T, I>(endpointConfigurationName, remoteAddress, Settings.Default.UserName, Settings.Default.Password);
+    }
+    public static T CreateClient<T, I>(string endpointConfigurationName, string remoteAddress, string userName, string password)
+      where T : ClientBase<I>, I
+      where I : class {
       T client;
       if (string.IsNullOrEmpty(endpointConfigurationName)) {
@@ -47,12 +56,83 @@
 
       if (!string.IsNullOrEmpty(remoteAddress)) {
-        client.Endpoint.Address = new EndpointAddress(remoteAddress);
+        SetEndpointAddress(client.Endpoint, remoteAddress);
       }
 
-      client.ClientCredentials.UserName.UserName = Settings.Default.UserName;
-      client.ClientCredentials.UserName.Password = Settings.Default.Password;
+      client.ClientCredentials.UserName.UserName = userName;
+      client.ClientCredentials.UserName.Password = password;
       client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
       return client;
     }
+
+    public static Disposable<I> CreateClient<I>(string endpointConfigurationName) where I : class {
+      return CreateClient<I>(endpointConfigurationName, null);
+    }
+    public static Disposable<I> CreateClient<I>(string endpointConfigurationName, string remoteAddress) where I : class {
+      return CreateClient<I>(endpointConfigurationName, remoteAddress, Settings.Default.UserName, Settings.Default.Password);
+    }
+    public static Disposable<I> CreateClient<I>(string endpointConfigurationName, string remoteAddress, string userName, string password) where I : class {
+      ChannelFactory<I> factory = GetChannelFactory<I>(endpointConfigurationName, userName, password);
+
+      if (!string.IsNullOrEmpty(remoteAddress)) {
+        SetEndpointAddress(factory.Endpoint, remoteAddress);
+      }
+      Disposable<I> disposable = new Disposable<I>(factory.CreateChannel());
+      disposable.OnDisposing += new EventHandler<EventArgs<object>>(disposable_OnDisposing);
+
+      return disposable;
+    }
+
+    private static void disposable_OnDisposing(object sender, EventArgs<object> e) {
+      DisposeCommunicationObject((ICommunicationObject)e.Value);
+      ((Disposable)sender).OnDisposing -= new EventHandler<EventArgs<object>>(disposable_OnDisposing);
+    }
+
+    private static IDictionary<ChannelProperties, ChannelFactory> channelFactoryCache = new Dictionary<ChannelProperties, ChannelFactory>();
+    private static ChannelFactory<I> GetChannelFactory<I>(string endpointConfigurationName, string userName, string password) where I : class {
+      ChannelProperties key = new ChannelProperties(typeof(I), endpointConfigurationName, userName, password);
+      if (!channelFactoryCache.ContainsKey(key)) {
+        channelFactoryCache.Add(key, new ChannelFactory<I>(endpointConfigurationName));
+        channelFactoryCache[key].Credentials.UserName.UserName = userName;
+        channelFactoryCache[key].Credentials.UserName.Password = password;
+        channelFactoryCache[key].Credentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
+      }
+      return (ChannelFactory<I>)channelFactoryCache[key];
+    }
+
+    public static void DisposeCommunicationObject(ICommunicationObject obj) {
+      if (obj != null) {
+        if (obj.State != CommunicationState.Faulted && obj.State != CommunicationState.Closed) {
+          try { obj.Close(); }
+          catch { obj.Abort(); }
+        } else {
+          obj.Abort();
+        }
+      }
+    }
+
+    /// <summary>
+    /// This method changes the endpoint-address while preserving the identity-certificate defined in the config file
+    /// </summary>
+    private static void SetEndpointAddress(ServiceEndpoint endpoint, string remoteAddress) {
+      EndpointAddressBuilder endpointAddressbuilder = new EndpointAddressBuilder(endpoint.Address);
+      UriBuilder uriBuilder = new UriBuilder(endpointAddressbuilder.Uri);
+      uriBuilder.Host = remoteAddress;
+      endpointAddressbuilder.Uri = uriBuilder.Uri;
+      endpoint.Address = endpointAddressbuilder.ToEndpointAddress();
+    }
+  }
+
+  internal struct ChannelProperties {
+    public Type type;
+    public string endpointConfigurationName;
+    public string userName;
+    public string password;
+
+    public ChannelProperties(Type type, string endpointConfigurationName, string userName, string password) {
+      this.type = type;
+      this.endpointConfigurationName = endpointConfigurationName;
+      this.userName = userName;
+      this.password = password;
+    }
   }
 }
Index: /trunk/sources/HeuristicLab.Clients.Common/3.3/Disposable.cs
===================================================================
--- /trunk/sources/HeuristicLab.Clients.Common/3.3/Disposable.cs	(revision 4913)
+++ /trunk/sources/HeuristicLab.Clients.Common/3.3/Disposable.cs	(revision 4913)
@@ -0,0 +1,51 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 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 HeuristicLab.Common;
+
+namespace HeuristicLab.Clients.Common {
+  public class Disposable : IDisposable {
+    protected object obj;
+    public object Obj {
+      get { return obj; }
+    }
+
+    public Disposable(object obj) {
+      this.obj = obj;
+    }
+
+    public void Dispose() {
+      if (OnDisposing != null)
+        OnDisposing(this, new EventArgs<object>(obj));
+    }
+
+    public event EventHandler<EventArgs<object>> OnDisposing;
+  }
+
+  public sealed class Disposable<T> : Disposable {
+    public new T Obj {
+      get { return (T)base.obj; }
+    }
+
+    public Disposable(T obj) : base(obj) { }
+  }
+}
Index: /trunk/sources/HeuristicLab.Clients.Common/3.3/HeuristicLab.Clients.Common-3.3.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Clients.Common/3.3/HeuristicLab.Clients.Common-3.3.csproj	(revision 4912)
+++ /trunk/sources/HeuristicLab.Clients.Common/3.3/HeuristicLab.Clients.Common-3.3.csproj	(revision 4913)
@@ -115,4 +115,5 @@
   <ItemGroup>
     <Compile Include="ClientFactory.cs" />
+    <Compile Include="Disposable.cs" />
     <Compile Include="HeuristicLabClientsCommonPlugin.cs" />
     <Compile Include="PasswordDialog.cs">
@@ -140,4 +141,8 @@
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\..\HeuristicLab.Common\3.3\HeuristicLab.Common-3.3.csproj">
+      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
+      <Name>HeuristicLab.Common-3.3</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
       <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
Index: /trunk/sources/HeuristicLab.Clients.Common/3.3/HeuristicLabClientsCommonPlugin.cs.frame
===================================================================
--- /trunk/sources/HeuristicLab.Clients.Common/3.3/HeuristicLabClientsCommonPlugin.cs.frame	(revision 4912)
+++ /trunk/sources/HeuristicLab.Clients.Common/3.3/HeuristicLabClientsCommonPlugin.cs.frame	(revision 4913)
@@ -28,4 +28,5 @@
   [Plugin("HeuristicLab.Clients.Common", "3.3.2.$WCREV$")]
   [PluginFile("HeuristicLab.Clients.Common-3.3.dll", PluginFileType.Assembly)]
+  [PluginDependency("HeuristicLab.Common", "3.3")]
   public class HeuristicLabClientsCommonPlugin : PluginBase {
   }
