MSMQ侦听器引发错误

MSMQ侦听器引发错误

本文介绍了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)

推荐答案

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侦听器引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 08:54