473,803 Members | 2,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MSMQ and the Message.Body property

Hi,

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
message.

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

myQueue.Formatt er = new XmlMessageForma tter( 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?
thx

Kimmo Laine
Nov 16 '05 #1
0 4074

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3726
by: Andrew Gordon | last post by:
I'm investigating getting Microsoft Navision to do stuff from a Python script. The recommended way seems to be to use message queues (MSMQ). I can get Navision to send a message to itself fine. I found a couple of code example in an ancient message in this newsgroup. The send.py one I changed to the following: from win32com.client import gencache msmq = gencache.EnsureModule('{D7D6E071-DCCD-11D0-AA4B-0060970DEBAE}', 0, 1, 0) qi =...
5
8002
by: Pete Loveall | last post by:
I have a server application that monitors a private local queue for messages. The message sent to it has a label and a response queue defined. It works correctly when the queue is accessed via another program. However, when I attempt to Send a message from an ASP.NET VB page, I get "One or more of the passed properties are invalid." I have tried different combinations of the non-transactional Send() with no success. My Windows\Temp...
1
793
by: **** KiteOregon **** | last post by:
I need to send & receive XML Document Objects via the Message Queue. We have several applications that insert XML Document Object into the message queue. This works with no problem. I am trying to write an async MSMQ listener that will handle these XML Document Objects. No matter what i seem to try i keep getting various errors. So, how do i get an XML Document Object back out of the Message Queue. Thanks
1
3669
by: Richard Atkinson | last post by:
I would appreciate help on the Microsoft Message Queue. Basically I would like to Serialize an entire class into a message queue and then reinstantiate the class in another application from the message queue with all properties, variables etc in tact. What is the best way to do this ie which formatter to use and how do you deal with arrays collections properties etc defined in the class since there seems to be a limitation on what you...
0
1416
by: yonirabin | last post by:
Hello, I am building a system in C# 2.0 using the master - worker design pattern The system is supposed to work as follows: 1. The Master sends Command objects to the workers 2. All Commands are derived from AbstractCommand class since the system is distributed and should be presistant, I want to use MSMQ to pass the Command object to the Workers The object which I send to the MSMQ is a message containing an object
3
6394
by: yonirabin | last post by:
Hello, I am building a system in C# 2.0 using the master - worker design pattern The system is supposed to work as follows: 1. The Master sends Command objects to several workers 2. All Commands are derived from AbstractCommand class (but are significantly different from each other) Since the system is distributed and should be presistant, I want to use
4
6278
by: IdleBrain | last post by:
I wrote an application that puts in a message into MSMQ using C++ and MFC. If I try to put a message called 'sample' I see that the body of the message in MSMQ would be set to: 's.a.m.p.l.e'. On the other hand I have a C# application that reads the same message queue and it expects the body format to be: '<?xml version="1.0"? >..<string>sample</string>'
1
8728
by: Tbone | last post by:
Is there any way to send a Message without having the .NET framework add the "serialization" data to the body of the message? I am sending binary structures in the message and I need full control over what is in the body of the message. I see some extra bytes before and after the message I asked the system to write. I am looking for a way to get rid of those so I can send binary structures in messages to a C++ program and vice versa. ...
0
1460
by: thajudeen | last post by:
Hi , I am able to send a text file (.txt) to a message queue (MSMQ). But i am not able to receive the .txt file from the message queue. Please help how to proceed. I am Using BodyStream property to send the content of the text file. In the message queue am able to see the content data present. I think by default MSMQ uses xmlformatter. Below is code for sending i have used ------------------------------------------------------- ...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10550
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10317
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6844
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.