Fetching Data of a private msmq using GetAllMessages method of MessageQueue class

27 Views Asked by At

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

0

There are 0 best solutions below