title: Dynamically create host wcf
body: <p>I have 3 projects.
  ServHost
  ServManager
  ServClient</p>
  
  <p>My intention is to use send data from client to ServManager and let ServManager dynamically create host endpoints. And, then consuming the Host endpoints using ChannelFactory created at ServManager.</p>
  
  <p>ServHost.cs has the following method:</p>
  
  <pre><code>    public void createWorkerHost(Uri addr, RequiredClass workerObj)
      {
          ServiceHost host;
          host = new ServiceHost(workerObj, addr);
          host.AddServiceEndpoint(typeof(IRequiredClass), new BasicHttpBinding(), "");
          var smb = new ServiceMetadataBehavior();
          smb.HttpGetEnabled = true;
          host.Description.Behaviors.Add(smb);
          host.Open();
      }
  </code></pre>
  
  <p>ServManager.cs has the following methods:</p>
  
  <pre><code>    private void Initialize()
      {
              mChannelFactories = new ChannelFactory&lt;IRequiredClass&gt;[0];
              RequiredClass rqObj = new RequiredClass(var1 obj); 
              var endpointAddress = CreateEndPointAddress(1);
              WorkerHost.WorkerHost.createWorkerHost(new Uri(endpointAddress),rqObj);
              mChannelFactories[0] = CreateChannelFactory(endpointAddress);        
      }
  
  
      public static ChannelFactory&lt;IRequiredClass&gt; CreateChannelFactory(string address)
      {
          try
          {
              var binding = new BasicHttpBinding();
              EndpointAddress endpointAddrress = new EndpointAddress(address);
              var myChannelFactory = new ChannelFactory&lt;IRequiredClass&gt;(binding, endpointAddrress);                
              return myChannelFactory;
          }
          catch (Exception ex)
          {
              throw ex;
          }
      }
  </code></pre>
  
  <p>Here, I am able to call ServManager and get data from ServClient over there. After I call the createWorkerHost method, and create the ChannelFactory, when I am trying to execute the exposed method in IRequiredClass using the channel from ChannelFactory, I am getting a TimeoutException. </p>
  
  <p>Its because, the endpoint url keeps on loading until the whole project is debugged. How can I have the url to be loaded without having the whole project debugged.</p>