消息队列错误:无法找到能够读取消息的格式 [英] Message Queue Error: cannot find a formatter capable of reading message

查看:536
本文介绍了消息队列错误:无法找到能够读取消息的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写在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
}

这篇关于消息队列错误:无法找到能够读取消息的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆