消息队列错误:无法找到能够读取消息的格式

消息队列错误:无法找到能够读取消息的格式

问题描述:

我写在C#中的消息到消息队列如下:

I'm writing messages to a Message Queue in C# as follows:

queue.Send(new Message("message"));



我试图读取消息如下:

I'm trying to read the messages as follows:

Messages messages = queue.GetAllMessages();
foreach(Message m in messages)
{
  String message = m.Body;
  //do something with string
}



不过我发现了一个东西错误消息,它说:无法找到能够读取该消息格式化?

However I'm getting an error message which says: "Cannot find a formatter capable of reading this message."

我在做什么错

我加入了格式化每个消息解决了这个问题。添加一个格式化到队列没有工作。

I solved the problem by adding a formatter to each message. Adding a formatter to the queue didn't work.

Messages messages = queue.GetAllMessages();
foreach(Message m in messages)
{
  m.Formatter = new XmlMessageFormatter(new String[] { "System.String,mscorlib" });
  String message = m.Body;

  //do something with string
}