title: How to send multiple objects using named pipes?
body: <p>I'm trying to send 4 parameters - one integer, one bool and two strings from server to client using named pipes.
  I've tried different ways, but still not succeeded.
  First way - I just converted all parameters to string and tried to send like that, but on client I received all parameters as null:</p>
  
  <p>Server code:</p>
  
  <pre><code>   static void StartServer()
          {
              var server = new NamedPipeServerStream("PipesEnroll", PipeDirection.InOut);
  
                  while (true)
                  {
                      server.WaitForConnection();
                      StreamWriter writer = new StreamWriter(server);
                      string terminalTemplate;
                      string matcherTemplate;
                      int mathVersionNumber = 9;
                      int numberFingers;
                      bool isOk = Enroll.EnrollWithoutWCF(retrievedList, mathVersionNumber, out terminalTemplate, out matcherTemplate, out numberFingers);
  
                      writer.WriteLine(isOk.ToString());
                      writer.WriteLine(terminalTemplate);
                      writer.WriteLine(matcherTemplate);
                      writer.WriteLine(numberFingers.ToString());
                      writer.Flush();
  
                      server.Disconnect();
             }
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code>                   using (var client = new NamedPipeClientStream(".", "PipesEnroll", PipeDirection.InOut))
                      {
                          client.Connect();
                          StreamReader reader = new StreamReader(client);
  
                            bool isOK = Convert.ToBoolean(reader.ReadLine());
                            string terminalTemplate = reader.ReadLine();
                            string matcherTemplate = reader.ReadLine();
                            int numberFingers = Convert.ToInt32(reader.ReadLine());
  
                      }
  </code></pre>
  
  <p>Second way I did is creating list of strings and serialized it on server, deserialized on client using BinaryFormatter, but got this exception:"System.Runtime.Serialization.SerializationException: End of Stream encountered before parsing was completed" </p>
  
  <p>Server code: </p>
  
  <pre><code>   var server = new NamedPipeServerStream("PipesEnroll", PipeDirection.InOut);
  while (true)
  {
          server.WaitForConnection();
          StreamWriter writer = new StreamWriter(server);   
  List&lt;string&gt; sendList = new List&lt;string&gt;();
    sendList.Add(isOk.ToString());
    sendList.Add(terminalTemplate);
    sendList.Add(matcherTemplate);
    sendList.Add(numberFingers.ToString());
    BinaryFormatter formatterSerialize = new BinaryFormatter();
    formatterSerialize.Serialize(writer.BaseStream, sendList);
    writer.Flush();
    server.Disconnect();
   }
  </code></pre>
  
  <p>Client code:</p>
  
  <pre><code>using (var client = new NamedPipeClientStream(".", "PipesEnroll", PipeDirection.InOut))
            {
               client.Connect();
               StreamReader reader = new StreamReader(client);   
   BinaryFormatter formatterDeserialize = new BinaryFormatter();
      List&lt;string&gt; retrievedList =  (List&lt;string&gt;) formatterDeserialize.Deserialize(reader.BaseStream);
  }
  </code></pre>