public static bool WriteStreamMessage(this System.Net.Sockets.NetworkStream stream, System.IO.MemoryStream message) { _log.DebugFormat("In WriteStreamMessage, message={0}", (message == null) ? "null" : message.GetType().Name); message.Seek(0, System.IO.SeekOrigin.Begin); byte[] messageBytes = message.ToArray(); return(stream.WriteStreamMessage(messageBytes)); }