title: WCF: Client invoking method, but not returning
body: <p>server client architecture. No IIS involved. Both applications are WinForm!</p>
  
  <p>I've made the following interfaces in a shared Library:</p>
  
  <pre><code>[ServiceContract(SessionMode=SessionMode.Required,
          CallbackContract=typeof(ClientInterface))]
      public interface RequestInterface
      {
          [OperationContract]
          void Subscribe();
  
          [OperationContract]
          MyInterface GetInterface();
      }
  
      public interface MyInterface
      {
          [DataMember]
          List&lt;MySubInterface&gt; SubClasses{get;}
      }
  
      public interface MySubInterface
      {
          [DataMember]
          int Value { get; }
      }
  </code></pre>
  
  <p>And implemented them on the server like this:</p>
  
  <pre><code>public class RequestHandler : RequestInterface
  {
      private List&lt;ClientInterface&gt; iClients = new List&lt;ClientInterface&gt;();
  
      public MyInterface GetInterface()
      {
          List&lt;MySubInterface&gt; tList = new List&lt;MySubInterface&gt;();
          Form1.AddText("method invoked by:" + Thread.CurrentContext.ToString());
          foreach (RealSubclass tClass in Form1.iClass.SubClasses)
          {
              tList.Add(new TransmissionSubclass(tClass.Value));
          }
  
          TransmissionClass tTC = new TransmissionClass(tList);
          Form1.AddText("created:" + tTC);
          return tTC;
      }
      public void Subscribe()
      {
          Form1.AddText("subscribing:" + OperationContext.Current.GetCallbackChannel&lt;ClientInterface&gt;());
          iClients.Add(OperationContext.Current.GetCallbackChannel&lt;ClientInterface&gt;());
          fireClassEvent("halloWelt");
      }
  }
  </code></pre>
  
  <p>On the client I'm doing the following piece of code, trying to invoke the GetInterface() method:</p>
  
  <pre><code>        ClientClass tClass = new ClientClass(this);
          DuplexChannelFactory&lt;RequestInterface&gt; pipeFactory =
           new DuplexChannelFactory&lt;RequestInterface&gt;(
              tClass,
              new NetNamedPipeBinding(),
              new EndpointAddress(
                 "net.pipe://localhost/Request"));
  
          RequestInterface pipeProxy = pipeFactory.CreateChannel();
  
          //pipeProxy.Subscribe(); -- works like a charm
          MyInterface tInterface = pipeProxy.GetInterface(); // doesn't work
          fillListView(tInterface);
  </code></pre>
  
  <p>However, when debugging through the client step by step the debugging breaks at the marked line and seems to exit this function.<br>
  It only returns to 'step by step' mode when I close the application's form.<br>
  On the other hand I can see from logging output on my server, that the GetInterface() method gets executed.<br>
  The <code>TransmissionClass</code> and <code>TransmissionSubclass</code> are both in the shared library and implement <code>MyInterface / MySubInterface</code></p>
  
  <pre><code>[DataContract]
  [Serializable]
  public class TransmissionClass : MyInterface
  {
      [DataMember]
      public List&lt;MySubInterface&gt; SubClasses{get;private set;}
  
      public TransmissionClass(List&lt;MySubInterface&gt; aList)
      {
          SubClasses = aList;
      }
  
      public override string ToString()
      {
          return "TransmissionClass,Count:" + SubClasses.Count;
      }
  }
  </code></pre>
  
  <p>WCF-initialization on the server side:</p>
  
  <pre><code>using (ServiceHost host = new ServiceHost(
              typeof(RequestHandler),
              new Uri[] { new Uri("net.pipe://localhost") }))
                      {
  
                          ServiceDebugBehavior tBehavior = new ServiceDebugBehavior();
                          if (null == tBehavior)
                          {
                              host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });
                          }
                          else if (!tBehavior.IncludeExceptionDetailInFaults)
                          {
                              tBehavior.IncludeExceptionDetailInFaults = true;
                          }
                          host.AddServiceEndpoint(typeof(RequestInterface),
                            new NetNamedPipeBinding(), "Request");
  
                          host.Open();
                          Application.Run(new Form1());
  
                          host.Close();
          }
  </code></pre>