public static void SerializeResponse( Request message, Stream stream ) { IProtocolFormatter formatter = message.GetFormatter(); MessageWriter.writeObject( message, formatter ); ProtocolBytes protocolBytes = formatter.GetBytes(); formatter.Cleanup(); stream.Write( protocolBytes.bytes, 0, protocolBytes.length ); stream.Flush(); }