Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 9th, 2012  |  syntax: None  |  size: 1.03 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. I get an InvalidOperationException When Invoking a Service
  2. namespace HelloIndigo
  3. {
  4.   public class Service : IHelloIndigoService
  5.   {
  6.       public string HelloIndigo()
  7.       {
  8.         return "Hello Indigo";
  9.       }
  10.   }
  11.  
  12.   [ServiceContract(Namespace = "http://www.thatindigogirl.com/samples/2006/06")]
  13.   interface IHelloIndigoService
  14.   {
  15.     [OperationContract]
  16.     string HelloIndigo();
  17.   }
  18. }
  19.        
  20. namespace Host
  21. {
  22.   class Program
  23.   {
  24.     static void Main(string[] args)
  25.     {
  26.       using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.Service),
  27.                                     new Uri("http://localhost:8000/HelloIndigo")))
  28.       {
  29.         host.AddServiceEndpoint(typeof(HelloIndigo.Service),
  30.                                     new BasicHttpBinding(),"Service");
  31.         host.Open();
  32.         Console.WriteLine("Press enter to terminate the host service");
  33.         Console.ReadLine();
  34.       }
  35.     }
  36.   }
  37. }
  38.        
  39. host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService),
  40.                                 new BasicHttpBinding(),"Service");