C# .NET - MSMQ listener can't read messages. Can detect the messages but can't read the body

Asked By jason smith on 21-Nov-06 07:52 PM

The MSMQListner (C#)is able to Receive (mymessageq.Receive) but can't read the body or subject of the message.

In the messages sending application (VB.net), I wrote,

dim queue as new MessageQueue()

queue.send("hello world");

In the listner application, when the control hits the following code, I get the above message

MessageQueue MyMessageQ;

Message MyMessage;

try

{

    MyMessag = MyMessageQ.Receive();

//system.InvalidOperationException

    MyMessage.Body;


Should I do some kind of formatting before I send the message?

thanks

nath

Make sure the formatter is set - Peter Bromberg replied to jason smith on 21-Nov-06 09:28 PM

before you send, and before you receive.

Also, typically you would send an object, not just "text". So you need to have a copy of the assembly with the class you expect to serialize / deserialize at each end.