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?