Question : Sending Object Via MessageQueue

Dear All,

I am triying to use MessageQueue to send object. I did similiar to the code here:

http://www.devx.com/dotnet/Article/27922/1763/page/2


However I get error message when receiving that message. In shot I cannot get msg.body and the internal error is:

 Body: 'mes.Body' threw an exception of type 'System.ArgumentNullException' --- {
"Value cannot be null.
Parameter name: type"}


Could anyone please help?

Thanks in advance!

Answer : Sending Object Via MessageQueue

Well, this differs from the sample you started with. Here are some things to look at:
- Why do both send and receive start with "if (MessageQueue.Exists..." If the message queue already exists, why do you create another one? Doing so will put the old one on the garbage collector.
- The example you started with calls MessageQueue.Send with argument of your custom object, but your new code creates a Message object first and assigns the custom object to the Message.Body. What happens if you go back to the example and try calling Send with argument of custom object?
- The example you started with assigns the Formatter to the MessageQueue object, but your code assigns the Formatter to the Message object (on the send side). What happens if you assign the MessageQueue.Formatter instead?
Random Solutions  
 
programming4us programming4us