public bool SendMessage <T>(T msgBody) { try { using (var queue = new Msmq.MessageQueue(QueuePath)) { var message = new Msmq.Message(); var obj = JsonConvertor.SerializeObject(msgBody); // we use json for more optimized queue size, default is xml message.BodyStream = new MemoryStream(Encoding.UTF8.GetBytes(obj)); // convert json to array of bytes & put it into memorystream for using in queue queue.Send(message); return(true); } } catch (Exception ex) { LogManager.Error(ex); } return(false); // if it fails in any reason, the result is false }