I am trying to fetch all the messages of a private queue by using this code and want to write these messages in XML file .When I was unsuccessful to do that then I try this code.
string queuePath = ".\\private$\\test";
MessageQueue queue = new MessageQueue(queuePath);
Message[] messages = queue.GetAllMessages();
foreach (Message msg in messages)
{
Console.WriteLine(msg.Body);
}
I found this code from Microsoft Official website but I am getting This error
System.InvalidOperationException: 'Cannot find a formatter capable of reading this message.
Please suggest me the solution