title: Call WCF - Host from Windows application
body: <p>I have 4 projects in my solution. 2 WCF Service Library projects called <code>GetDetfromDB</code>, <code>ModifyDBService</code>, one console application which has reference of these WCF service libraries and a windows application to call this WCF Service.</p>
  
  <p>I made the reference of the console app in windows app. Now I am able to call the client app from window app.</p>
  
  <p>But now how can I invoke the services which are referred in console app by calling from windows app?</p>
  
  <p>Note: When I press F5 or Debugger-->Start new instance both service runs correctly from my console. I configured all the binding,endpoints address correctly. I want how to call it programmatically.</p>
  
  <p>Here is my console application code:</p>
  
  <pre><code>namespace ServiceHostConsole
  {
      public class Program
      {
          static void Main(string[] args)
          {
              Console.WriteLine("enter to start");
              Console.Read();
  
              Type serviceType = typeof(GetDetfromDB.ImpService);
              Type serviceModifyDB = typeof(ModifyDBService.Manipulate);
  
              ServiceHost host1 = new ServiceHost(serviceModifyDB);
              host1.Open();
  
              using (ServiceHost host = new ServiceHost(serviceType))
              {
                  host.Open();
  
                  Console.WriteLine("The Product Service is available");
                  Console.ReadLine(); host.Close();
              }
  
              Console.WriteLine("Please enter to close modify service");
              Console.Read();
              host1.Close();
          }
  
          public string returnPath()
          {
              string folder = Environment.CurrentDirectory;
              return folder;
          }
      }
  }
  </code></pre>
  
  <p>From Windows application I am calling like this ....</p>
  
  <pre><code> public Form1()
   {
        InitializeComponent();
  
        ServiceHostConsole.Program pb = new ServiceHostConsole.Program();
        Process.Start(pb.returnPath()+ @"\ServiceHostConsole.exe");
   }
  </code></pre>
  
  <p>Now I am getting the following error when program tries to open my service..</p>
  
  <blockquote>
    <p>Service 'ModifyDBService.Manipulate' has zero application
    (non-infrastructure) endpoints. This might be because no
    configuration file was found for your application, or because no
    service element matching the service name could be found in the
    configuration file, or because no endpoints   were defined in the
    service element</p>
  </blockquote>
  
  <p>I am suspecting that I am calling blindly the method only and not invoking the service. </p>
  
  <p>Kindly help me to get out of this issue, I have been struggling for the past 5 days for this.</p>
  
  <p>I need to publish my windows application and when i click setup both my windows application and client application with invoked services should open. This is my requirement.</p>
  
  <p>My App.config of ServiceHostConsole look like this,</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;services&gt;
              &lt;service name="GetDetfromDB.ImpService"&gt;
                  &lt;endpoint address="http://localhost:8080/MyService" binding="basicHttpBinding"
                      bindingConfiguration="" contract="GetDetfromDB.IGetExpenseValuestype" /&gt;
              &lt;/service&gt;
              &lt;service name="ModifyDBService.Manipulate"&gt;
                  &lt;endpoint address="http://localhost:8081/MyService1." binding="basicHttpBinding"
                      bindingConfiguration="" contract="ModifyDBService.IManipulateDB" /&gt;
              &lt;/service&gt;
          &lt;/services&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>