MSMQ侦听器引发错误 [英] MSMQ Listener throwing error

查看:79
本文介绍了MSMQ侦听器引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的MSMQ侦听器代码调用Windows Servce,但是当我启动窗口服务时,它将抛出以下消息.

不确定缺少的地方和内容,任何帮助都将不胜感激

来自事件日志的错误消息

服务无法启动. System.InvalidOperationException:找不到能够读取此消息的格式化程序.在System.Messaging.Message.get_Body()在CRSMessagePipeline.CRSService.processMessage()在CRSMessagePipeline.CRSService.OnStart(String [] args)在System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

Hello All,

My MSMQ listener code call the windows servce but when i start my window service it throws below message.

Am not sure where and what am missing,any help much appreciated

ERROR Msg from Event Log

Service cannot be started. System.InvalidOperationException: Cannot find a formatter capable of reading this message. at System.Messaging.Message.get_Body() at CRSMessagePipeline.CRSService.processMessage() at CRSMessagePipeline.CRSService.OnStart(String[] args) at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)

推荐答案

该错误消息明确指出了问题所在.您的MSMQ队列读取器未实现正确的格式化程序.对于代码而言,知道将以哪种格式读取队列对象非常重要.

以下是示例代码,根据您的数据类型实现相同的代码:

The error message clearly states the problem. Your MSMQ queue reader has not implemented the correct formatter. It is very important for the code to know in which format will the queue object be read.

Below is the sample code, implement the same as per your data type:

MessageQueue queue = new MessageQueue(@".\MyQueue");
System.Messaging.Message msg = new System.Messaging.Message();
msg = queue.Receive();
msg.Formatter = new System.Messaging.XmlMessageFormatter(new String[] { "System.String,mscorlib" });



希望有帮助.



Hope that helps.


这篇关于MSMQ侦听器引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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