470,855 Members | 2,840 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,855 developers. It's quick & easy.

MSMQ and the Message.Body property


how can i be sure that the MSMQ Message.Body property contains something
valid? If i send the message like this:

public void SendMyMessage( int msgCode, object msgData ) {
Message msg = new Message();
msg.AppSpecific = msgCode;
msg.Body = msgData;

m_MyQueue.Send( msg );

Sometimes the msgData is valid object (array of objects actually) and
sometimes its just null. When its null and i try to check it

if( msg.Body != null ) {
// . . .

I get XmlException - "The root element is missing"! If i but empty string
into Body-field when i donīt have data: XmlException again, with the same

The Message.BodyType seems to be allways 0. MessageQueue formatter is set
like this:

myQueue.Formatter = new XmlMessageFormatter( new Type[] { typeof(
object[] ) } );
I could do it like this

object[] data;
try {
data = ( object[] )msg.Body;
} catch ( Exception exc ) {
data = null;

but i donīt like this... Is there a better way? Am i missing something?

Kimmo Laine
Nov 16 '05 #1
0 3881

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Andrew Gordon | last post: by
5 posts views Thread by Pete Loveall | last post: by
1 post views Thread by **** KiteOregon **** | last post: by
1 post views Thread by Richard Atkinson | last post: by
reply views Thread by yonirabin | last post: by
3 posts views Thread by yonirabin | last post: by
4 posts views Thread by IdleBrain | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.